Skip to content

Commit 41d184d

Browse files
committed
Make AppState zero-cost.
1 parent adaa9d9 commit 41d184d

3 files changed

Lines changed: 28 additions & 18 deletions

File tree

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1 @@
1-
'use strict';
2-
3-
4-
var active = "active";
5-
6-
var background = "background";
7-
8-
var inactive = "inactive";
9-
10-
exports.active = active;
11-
exports.background = background;
12-
exports.inactive = inactive;
13-
/* No side effect */
1+
/* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */

‎bs-react-native-next/src/apis/AppState.re‎

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1-
type t;
1+
type t = string;
22

3-
external fromString: string => t = "%identity";
3+
[@bs.inline]
4+
let active = "active";
45

5-
let active = "active"->fromString;
6-
let background = "background"->fromString;
7-
let inactive = "inactive"->fromString;
6+
[@bs.inline]
7+
let background = "background";
8+
9+
[@bs.inline]
10+
let inactive = "inactive";
811

912
[@bs.scope "AppState"] [@bs.module "react-native"]
1013
external currentState: t = "currentState";
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
type t;
2+
3+
[@bs.inline "active"]
4+
let active: t;
5+
6+
[@bs.inline "background"]
7+
let background: t;
8+
9+
[@bs.inline "inactive"]
10+
let inactive: t;
11+
12+
[@bs.scope "AppState"] [@bs.module "react-native"]
13+
external currentState: t = "currentState";
14+
15+
[@bs.scope "AppState"] [@bs.module "react-native"]
16+
external addEventListener: (string, unit => unit) => EventSubscription.t = "";
17+
18+
[@bs.scope "AppState"] [@bs.module "react-native"]
19+
external removeEventListener: (string, unit => unit) => unit = "";

0 commit comments

Comments
 (0)