Skip to content

Commit bb623e6

Browse files
draperunnerfacebook-github-bot
authored andcommitted
Allow Animation EndResult callback to return Promise (#25793)
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
1 parent e78c013 commit bb623e6

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

Libraries/Animated/src/NativeAnimatedModule.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import type {TurboModule} from '../../TurboModule/RCTExport';
1414
import * as TurboModuleRegistry from '../../TurboModule/TurboModuleRegistry';
1515

1616
type EndResult = {finished: boolean};
17-
type EndCallback = (result: EndResult) => void;
17+
type EndCallback = (result: EndResult) => void | Promise<void>;
1818

1919
export type EventMapping = {|
2020
nativeEventPath: Array<string>,

Libraries/Animated/src/animations/Animation.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const NativeAnimatedHelper = require('../NativeAnimatedHelper');
1414
import type AnimatedValue from '../nodes/AnimatedValue';
1515

1616
export type EndResult = {finished: boolean};
17-
export type EndCallback = (result: EndResult) => void;
17+
export type EndCallback = (result: EndResult) => void | Promise<void>;
1818

1919
export type AnimationConfig = {
2020
isInteraction?: boolean,

0 commit comments

Comments
 (0)