Skip to content

Commit 3ad271f

Browse files
authored
Define event names for AppState listeners using trick for variants (#449)
1 parent a3b1cdb commit 3ad271f

3 files changed

Lines changed: 25 additions & 6 deletions

File tree

‎reason-react-native/src/apis/AppState.md‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,15 @@ let inactive: t;
2020
external currentState: t = "currentState";
2121
2222
[@bs.scope "AppState"] [@bs.module "react-native"]
23-
external addEventListener: (string, unit => unit) => EventSubscription.t = "";
23+
external addEventListener:
24+
([@bs.string] [ | `change(t => unit) | `memoryWarning(unit => unit)]) =>
25+
EventSubscription.t =
26+
"";
2427
2528
[@bs.scope "AppState"] [@bs.module "react-native"]
26-
external removeEventListener: (string, unit => unit) => unit = "";
29+
external removeEventListener:
30+
([@bs.string] [ | `change(t => unit) | `memoryWarning(unit => unit)]) =>
31+
unit =
32+
"";
33+
2734
```

‎reason-react-native/src/apis/AppState.re‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,13 @@ let inactive = "inactive";
1313
external currentState: t = "currentState";
1414

1515
[@bs.scope "AppState"] [@bs.module "react-native"]
16-
external addEventListener: (string, unit => unit) => EventSubscription.t = "";
16+
external addEventListener:
17+
([@bs.string] [ | `change(t => unit) | `memoryWarning(unit => unit)]) =>
18+
EventSubscription.t =
19+
"";
1720

1821
[@bs.scope "AppState"] [@bs.module "react-native"]
19-
external removeEventListener: (string, unit => unit) => unit = "";
22+
external removeEventListener:
23+
([@bs.string] [ | `change(t => unit) | `memoryWarning(unit => unit)]) =>
24+
unit =
25+
"";

‎reason-react-native/src/apis/AppState.rei‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,13 @@ let inactive: t;
1313
external currentState: t = "currentState";
1414

1515
[@bs.scope "AppState"] [@bs.module "react-native"]
16-
external addEventListener: (string, unit => unit) => EventSubscription.t = "";
16+
external addEventListener:
17+
([@bs.string] [ | `change(t => unit) | `memoryWarning(unit => unit)]) =>
18+
EventSubscription.t =
19+
"";
1720

1821
[@bs.scope "AppState"] [@bs.module "react-native"]
19-
external removeEventListener: (string, unit => unit) => unit = "";
22+
external removeEventListener:
23+
([@bs.string] [ | `change(t => unit) | `memoryWarning(unit => unit)]) =>
24+
unit =
25+
"";

0 commit comments

Comments
 (0)