Skip to content

Commit

Permalink
Allow Animation EndResult callback to return Promise (#25793)
Browse files Browse the repository at this point in the history
Summary:
I am sending an asynchronous function as callback to the `.start` method of `Animation.parallel([...]).start(callback)`. Flow does not like this, as the `EndCallback` type is saying that these callbacks must return `void`. Since my callback returns `Promise<void>` this results in an error.

Does it really matter what the callback returns?

## Changelog

[General] [Changed] - Make Animation EndCallback type allow any return value
Pull Request resolved: #25793

Test Plan: I have run `yarn flow`, which reported no errors.

Reviewed By: cpojer

Differential Revision: D16515465

Pulled By: osdnk

fbshipit-source-id: 420d29d262b65471e6e1ad4b5a126bf728336260
  • Loading branch information
draperunner authored and facebook-github-bot committed Jul 26, 2019
1 parent e78c013 commit bb623e6
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Libraries/Animated/src/NativeAnimatedModule.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import type {TurboModule} from '../../TurboModule/RCTExport';
import * as TurboModuleRegistry from '../../TurboModule/TurboModuleRegistry';

type EndResult = {finished: boolean};
type EndCallback = (result: EndResult) => void;
type EndCallback = (result: EndResult) => void | Promise<void>;

export type EventMapping = {|
nativeEventPath: Array<string>,
Expand Down
2 changes: 1 addition & 1 deletion Libraries/Animated/src/animations/Animation.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const NativeAnimatedHelper = require('../NativeAnimatedHelper');
import type AnimatedValue from '../nodes/AnimatedValue';

export type EndResult = {finished: boolean};
export type EndCallback = (result: EndResult) => void;
export type EndCallback = (result: EndResult) => void | Promise<void>;

export type AnimationConfig = {
isInteraction?: boolean,
Expand Down

0 comments on commit bb623e6

Please sign in to comment.