From bb623e698347756be83fa3bcfb37cb73aca5dee7 Mon Sep 17 00:00:00 2001 From: Mats Byrkjeland Date: Fri, 26 Jul 2019 03:38:03 -0700 Subject: [PATCH] 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` 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: https://github.com/facebook/react-native/pull/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 --- Libraries/Animated/src/NativeAnimatedModule.js | 2 +- Libraries/Animated/src/animations/Animation.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Libraries/Animated/src/NativeAnimatedModule.js b/Libraries/Animated/src/NativeAnimatedModule.js index 80ece9d69d0..23d738bbffc 100644 --- a/Libraries/Animated/src/NativeAnimatedModule.js +++ b/Libraries/Animated/src/NativeAnimatedModule.js @@ -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; export type EventMapping = {| nativeEventPath: Array, diff --git a/Libraries/Animated/src/animations/Animation.js b/Libraries/Animated/src/animations/Animation.js index 24482d22b7c..52301ff3902 100644 --- a/Libraries/Animated/src/animations/Animation.js +++ b/Libraries/Animated/src/animations/Animation.js @@ -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; export type AnimationConfig = { isInteraction?: boolean,