Add @flow to BackHandler

Summary:
Add flow to BackHandler
Fixed callsites

Reviewed By: TheSavior

Differential Revision: D8994015

fbshipit-source-id: 2b910f14b4462020a37a33a8bcff67cef07500a3
This commit is contained in:
Timothy Kukulski 2018-09-27 15:43:21 -07:00 committed by Facebook Github Bot
parent 39f6264a84
commit 471e8c168a
2 changed files with 9 additions and 5 deletions

View File

@ -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),
};
},

View File

@ -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) {},
};
}