From 471e8c168a07ec2f4efcd2cfa815232b1bc3cd26 Mon Sep 17 00:00:00 2001 From: Timothy Kukulski Date: Thu, 27 Sep 2018 15:43:21 -0700 Subject: [PATCH] Add @flow to BackHandler Summary: Add flow to BackHandler Fixed callsites Reviewed By: TheSavior Differential Revision: D8994015 fbshipit-source-id: 2b910f14b4462020a37a33a8bcff67cef07500a3 --- Libraries/Utilities/BackHandler.android.js | 6 ++++-- Libraries/Utilities/BackHandler.ios.js | 8 +++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/Libraries/Utilities/BackHandler.android.js b/Libraries/Utilities/BackHandler.android.js index 730f13b4e45..d6198a923c0 100644 --- a/Libraries/Utilities/BackHandler.android.js +++ b/Libraries/Utilities/BackHandler.android.js @@ -5,6 +5,7 @@ * LICENSE file in the root directory of this source tree. * * @format + * @flow */ 'use strict'; @@ -16,6 +17,7 @@ const DEVICE_BACK_EVENT = 'hardwareBackPress'; type BackPressEventName = $Enum<{ backPress: string, + hardwareBackPress: string, }>; const _backPressSubscriptions = []; @@ -61,7 +63,7 @@ RCTDeviceEventEmitter.addListener(DEVICE_BACK_EVENT, function() { * ``` */ const BackHandler = { - exitApp: function() { + exitApp: function(): void { DeviceEventManager.invokeDefaultBackPressHandler(); }, @@ -79,7 +81,7 @@ const BackHandler = { _backPressSubscriptions.push(handler); } return { - remove: () => BackHandler.removeEventListener(eventName, handler), + remove: (): void => BackHandler.removeEventListener(eventName, handler), }; }, diff --git a/Libraries/Utilities/BackHandler.ios.js b/Libraries/Utilities/BackHandler.ios.js index 2305dbd783b..6d986f9ce91 100644 --- a/Libraries/Utilities/BackHandler.ios.js +++ b/Libraries/Utilities/BackHandler.ios.js @@ -8,6 +8,7 @@ * On iOS, this just implements a stub. * * @format + * @flow */ 'use strict'; @@ -17,9 +18,10 @@ const TVEventHandler = require('TVEventHandler'); type BackPressEventName = $Enum<{ backPress: string, + hardwareBackPress: string, }>; -function emptyFunction() {} +function emptyFunction(): void {} /** * Detect hardware button presses for back navigation. @@ -100,12 +102,12 @@ if (Platform.isTV) { } else { BackHandler = { exitApp: emptyFunction, - addEventListener() { + addEventListener(_eventName: BackPressEventName, _handler: Function) { return { remove: emptyFunction, }; }, - removeEventListener: emptyFunction, + removeEventListener(_eventName: BackPressEventName, _handler: Function) {}, }; }