Skip to content

Commit a903d1b

Browse files
Naturalclarfacebook-github-bot
authored andcommitted
BackHandler: specify function return type for handler (#28192)
Summary: Following the comment DefinitelyTyped/DefinitelyTyped#42618 (comment) Modify the flowtype of BackHandler function to have more specific return type. ## Changelog [General] [Changed] - Changed type of BackHandler to be more specific. Pull Request resolved: #28192 Test Plan: No flow error in RNTester Reviewed By: TheSavior Differential Revision: D20771113 Pulled By: hramos fbshipit-source-id: 5ca65e2a2b3f8726b8fb4606473d8fad5b0ce730
1 parent 4d9fa4b commit a903d1b

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

Libraries/Utilities/BackHandler.android.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,11 @@ type TBackHandler = {|
6363
+exitApp: () => void,
6464
+addEventListener: (
6565
eventName: BackPressEventName,
66-
handler: Function,
66+
handler: () => ?boolean,
6767
) => {remove: () => void, ...},
6868
+removeEventListener: (
6969
eventName: BackPressEventName,
70-
handler: Function,
70+
handler: () => ?boolean,
7171
) => void,
7272
|};
7373
const BackHandler: TBackHandler = {
@@ -87,7 +87,7 @@ const BackHandler: TBackHandler = {
8787
*/
8888
addEventListener: function(
8989
eventName: BackPressEventName,
90-
handler: Function,
90+
handler: () => ?boolean,
9191
): {remove: () => void, ...} {
9292
if (_backPressSubscriptions.indexOf(handler) === -1) {
9393
_backPressSubscriptions.push(handler);
@@ -102,7 +102,7 @@ const BackHandler: TBackHandler = {
102102
*/
103103
removeEventListener: function(
104104
eventName: BackPressEventName,
105-
handler: Function,
105+
handler: () => ?boolean,
106106
): void {
107107
if (_backPressSubscriptions.indexOf(handler) !== -1) {
108108
_backPressSubscriptions.splice(

Libraries/Utilities/BackHandler.ios.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,11 @@ type TBackHandler = {|
5454
+exitApp: () => void,
5555
+addEventListener: (
5656
eventName: BackPressEventName,
57-
handler: Function,
57+
handler: () => ?boolean,
5858
) => {remove: () => void, ...},
5959
+removeEventListener: (
6060
eventName: BackPressEventName,
61-
handler: Function,
61+
handler: () => ?boolean,
6262
) => void,
6363
|};
6464

@@ -93,7 +93,7 @@ if (Platform.isTV) {
9393

9494
addEventListener: function(
9595
eventName: BackPressEventName,
96-
handler: Function,
96+
handler: () => ?boolean,
9797
): {remove: () => void, ...} {
9898
_backPressSubscriptions.add(handler);
9999
return {
@@ -103,7 +103,7 @@ if (Platform.isTV) {
103103

104104
removeEventListener: function(
105105
eventName: BackPressEventName,
106-
handler: Function,
106+
handler: () => ?boolean,
107107
): void {
108108
_backPressSubscriptions.delete(handler);
109109
},

Libraries/Utilities/__mocks__/BackHandler.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const BackHandler = {
1616

1717
addEventListener: function(
1818
eventName: BackPressEventName,
19-
handler: Function,
19+
handler: () => ?boolean,
2020
): {remove: () => void} {
2121
_backPressSubscriptions.add(handler);
2222
return {
@@ -26,7 +26,7 @@ const BackHandler = {
2626

2727
removeEventListener: function(
2828
eventName: BackPressEventName,
29-
handler: Function,
29+
handler: () => ?boolean,
3030
): void {
3131
_backPressSubscriptions.delete(handler);
3232
},

0 commit comments

Comments
 (0)