Skip to content

Commit 471e8c1

Browse files
Timothy Kukulskifacebook-github-bot
authored andcommitted
Add @flow to BackHandler
Summary: Add flow to BackHandler Fixed callsites Reviewed By: TheSavior Differential Revision: D8994015 fbshipit-source-id: 2b910f14b4462020a37a33a8bcff67cef07500a3
1 parent 39f6264 commit 471e8c1

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

Libraries/Utilities/BackHandler.android.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
* LICENSE file in the root directory of this source tree.
66
*
77
* @format
8+
* @flow
89
*/
910

1011
'use strict';
@@ -16,6 +17,7 @@ const DEVICE_BACK_EVENT = 'hardwareBackPress';
1617

1718
type BackPressEventName = $Enum<{
1819
backPress: string,
20+
hardwareBackPress: string,
1921
}>;
2022

2123
const _backPressSubscriptions = [];
@@ -61,7 +63,7 @@ RCTDeviceEventEmitter.addListener(DEVICE_BACK_EVENT, function() {
6163
* ```
6264
*/
6365
const BackHandler = {
64-
exitApp: function() {
66+
exitApp: function(): void {
6567
DeviceEventManager.invokeDefaultBackPressHandler();
6668
},
6769

@@ -79,7 +81,7 @@ const BackHandler = {
7981
_backPressSubscriptions.push(handler);
8082
}
8183
return {
82-
remove: () => BackHandler.removeEventListener(eventName, handler),
84+
remove: (): void => BackHandler.removeEventListener(eventName, handler),
8385
};
8486
},
8587

Libraries/Utilities/BackHandler.ios.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
* On iOS, this just implements a stub.
99
*
1010
* @format
11+
* @flow
1112
*/
1213

1314
'use strict';
@@ -17,9 +18,10 @@ const TVEventHandler = require('TVEventHandler');
1718

1819
type BackPressEventName = $Enum<{
1920
backPress: string,
21+
hardwareBackPress: string,
2022
}>;
2123

22-
function emptyFunction() {}
24+
function emptyFunction(): void {}
2325

2426
/**
2527
* Detect hardware button presses for back navigation.
@@ -100,12 +102,12 @@ if (Platform.isTV) {
100102
} else {
101103
BackHandler = {
102104
exitApp: emptyFunction,
103-
addEventListener() {
105+
addEventListener(_eventName: BackPressEventName, _handler: Function) {
104106
return {
105107
remove: emptyFunction,
106108
};
107109
},
108-
removeEventListener: emptyFunction,
110+
removeEventListener(_eventName: BackPressEventName, _handler: Function) {},
109111
};
110112
}
111113

0 commit comments

Comments
 (0)