Skip to content

Commit 3c20cce

Browse files
authored
add missing AppRegistry functions (#567)
1 parent 2eb4bdd commit 3c20cce

File tree

2 files changed

+194
-8
lines changed

2 files changed

+194
-8
lines changed

reason-react-native/src/apis/AppRegistry.md

Lines changed: 98 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,108 @@ wip: true
55
---
66

77
```reason
8+
type appKey = string;
9+
type section = string;
10+
type taskId = float;
11+
type taskKey = string;
12+
13+
type task('data) = 'data => Js.Promise.t(unit);
14+
type taskProvider('data) = unit => task('data);
15+
type taskCanceller = unit => unit;
16+
type taskCancelProvider = unit => taskCanceller;
17+
18+
type componentProvider('a) = unit => React.component('a);
19+
type wrapperComponentProvider('a, 'b) = 'b => React.component('a);
20+
21+
type appParameters;
22+
23+
external asAppParameters: 'a => appParameters = "%identity";
24+
25+
type appConfig;
26+
27+
[@bs.obj]
28+
external appConfig:
29+
(
30+
~appKey: string,
31+
~component: componentProvider('a)=?,
32+
~run: appParameters => unit=?,
33+
~section: bool=?,
34+
unit
35+
) =>
36+
appConfig =
37+
"";
38+
39+
type runnable('a) = {
40+
.
41+
"component": Js.Nullable.t(componentProvider('a)),
42+
"run": appParameters => unit,
43+
};
44+
45+
type registry('a) = {
46+
.
47+
"sections": array(section),
48+
"runnables": Js.Dict.t(runnable('a)),
49+
};
50+
51+
[@bs.module "react-native"] [@bs.scope "AppRegistry"]
52+
external getAppKeys: unit => array(appKey) = "";
53+
54+
[@bs.module "react-native"] [@bs.scope "AppRegistry"]
55+
external getRegistry: unit => registry('a) = "";
56+
57+
[@bs.module "react-native"] [@bs.scope "AppRegistry"]
58+
external getRunnable: appKey => option(runnable('a)) = "";
59+
860
[@bs.module "react-native"] [@bs.scope "AppRegistry"]
9-
external registerComponent: (string, unit => React.component('a)) => unit =
61+
external getSectionKeys: unit => array(string) = "";
62+
63+
[@bs.module "react-native"] [@bs.scope "AppRegistry"]
64+
external getSections: unit => Js.Dict.t(runnable('a)) = "";
65+
66+
// multiple externals
67+
[@bs.module "react-native"] [@bs.scope "AppRegistry"]
68+
external registerComponent: (appKey, componentProvider('a)) => unit = "";
69+
70+
// multiple externals
71+
[@bs.module "react-native"] [@bs.scope "AppRegistry"]
72+
external registerComponentWithSection:
73+
(appKey, componentProvider('a), section) => unit =
74+
"registerComponent";
75+
76+
[@bs.module "react-native"] [@bs.scope "AppRegistry"]
77+
external registerConfig: array(appConfig) => unit = "";
78+
79+
[@bs.module "react-native"] [@bs.scope "AppRegistry"]
80+
external registerRunnable: (appKey, appParameters => unit) => string = "";
81+
82+
[@bs.module "react-native"] [@bs.scope "AppRegistry"]
83+
external registerSection: (appKey, componentProvider('a)) => unit = "";
84+
85+
[@bs.module "react-native"] [@bs.scope "AppRegistry"]
86+
external runApplication: (appKey, 'a) => unit = "";
87+
88+
[@bs.module "react-native"] [@bs.scope "AppRegistry"]
89+
external setWrapperComponentProvider:
90+
wrapperComponentProvider('a, 'b) => unit =
1091
"";
1192
12-
type task('data) = 'data => Js.Promise.t(unit);
93+
[@bs.module "react-native"] [@bs.scope "AppRegistry"]
94+
external unmountApplicationComponentAtRootTag: string => unit = "";
1395
96+
// Android only
1497
[@bs.module "react-native"] [@bs.scope "AppRegistry"]
15-
external registerHeadlessTask: (string, unit => task('data)) => unit = "";
98+
external cancelHeadlessTask: (taskId, taskKey) => unit = "";
99+
100+
[@bs.module "react-native"] [@bs.scope "AppRegistry"]
101+
external registerCancellableHeadlessTask:
102+
(taskKey, taskProvider('data), taskCancelProvider) => unit =
103+
"";
104+
105+
[@bs.module "react-native"] [@bs.scope "AppRegistry"]
106+
external registerHeadlessTask: (taskKey, taskProvider('data)) => unit = "";
107+
108+
[@bs.module "react-native"] [@bs.scope "AppRegistry"]
109+
external startHeadlessTask: (taskId, taskKey, 'data) => unit = "";
16110
17111
// react-native-web
18112
type app = {
@@ -21,7 +115,6 @@ type app = {
21115
[@bs.meth] "getStyleElement": unit => React.element,
22116
};
23117
[@bs.module "react-native"] [@bs.scope "AppRegistry"]
24-
external getApplication: (string, {. "initialProps": 'a}) => app =
25-
"";
118+
external getApplication: (string, {. "initialProps": 'a}) => app = "";
26119
27120
```

reason-react-native/src/apis/AppRegistry.re

Lines changed: 96 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,104 @@
1+
type appKey = string;
2+
type section = string;
3+
type taskId = float;
4+
type taskKey = string;
5+
6+
type task('data) = 'data => Js.Promise.t(unit);
7+
type taskProvider('data) = unit => task('data);
8+
type taskCanceller = unit => unit;
9+
type taskCancelProvider = unit => taskCanceller;
10+
11+
type componentProvider('a) = unit => React.component('a);
12+
type wrapperComponentProvider('a, 'b) = 'b => React.component('a);
13+
14+
type appParameters;
15+
16+
external asAppParameters: 'a => appParameters = "%identity";
17+
18+
type appConfig;
19+
20+
[@bs.obj]
21+
external appConfig:
22+
(
23+
~appKey: string,
24+
~component: componentProvider('a)=?,
25+
~run: appParameters => unit=?,
26+
~section: bool=?,
27+
unit
28+
) =>
29+
appConfig =
30+
"";
31+
32+
type runnable('a) = {
33+
.
34+
"component": Js.Nullable.t(componentProvider('a)),
35+
"run": appParameters => unit,
36+
};
37+
38+
type registry('a) = {
39+
.
40+
"sections": array(section),
41+
"runnables": Js.Dict.t(runnable('a)),
42+
};
43+
44+
[@bs.module "react-native"] [@bs.scope "AppRegistry"]
45+
external getAppKeys: unit => array(appKey) = "";
46+
47+
[@bs.module "react-native"] [@bs.scope "AppRegistry"]
48+
external getRegistry: unit => registry('a) = "";
49+
50+
[@bs.module "react-native"] [@bs.scope "AppRegistry"]
51+
external getRunnable: appKey => option(runnable('a)) = "";
52+
53+
[@bs.module "react-native"] [@bs.scope "AppRegistry"]
54+
external getSectionKeys: unit => array(string) = "";
55+
156
[@bs.module "react-native"] [@bs.scope "AppRegistry"]
2-
external registerComponent: (string, unit => React.component('a)) => unit =
57+
external getSections: unit => Js.Dict.t(runnable('a)) = "";
58+
59+
// multiple externals
60+
[@bs.module "react-native"] [@bs.scope "AppRegistry"]
61+
external registerComponent: (appKey, componentProvider('a)) => unit = "";
62+
63+
// multiple externals
64+
[@bs.module "react-native"] [@bs.scope "AppRegistry"]
65+
external registerComponentWithSection:
66+
(appKey, componentProvider('a), section) => unit =
67+
"registerComponent";
68+
69+
[@bs.module "react-native"] [@bs.scope "AppRegistry"]
70+
external registerConfig: array(appConfig) => unit = "";
71+
72+
[@bs.module "react-native"] [@bs.scope "AppRegistry"]
73+
external registerRunnable: (appKey, appParameters => unit) => string = "";
74+
75+
[@bs.module "react-native"] [@bs.scope "AppRegistry"]
76+
external registerSection: (appKey, componentProvider('a)) => unit = "";
77+
78+
[@bs.module "react-native"] [@bs.scope "AppRegistry"]
79+
external runApplication: (appKey, 'a) => unit = "";
80+
81+
[@bs.module "react-native"] [@bs.scope "AppRegistry"]
82+
external setWrapperComponentProvider: wrapperComponentProvider('a, 'b) => unit =
383
"";
484

5-
type task('data) = 'data => Js.Promise.t(unit);
85+
[@bs.module "react-native"] [@bs.scope "AppRegistry"]
86+
external unmountApplicationComponentAtRootTag: string => unit = "";
87+
88+
// Android only
89+
[@bs.module "react-native"] [@bs.scope "AppRegistry"]
90+
external cancelHeadlessTask: (taskId, taskKey) => unit = "";
91+
92+
[@bs.module "react-native"] [@bs.scope "AppRegistry"]
93+
external registerCancellableHeadlessTask:
94+
(taskKey, taskProvider('data), taskCancelProvider) => unit =
95+
"";
96+
97+
[@bs.module "react-native"] [@bs.scope "AppRegistry"]
98+
external registerHeadlessTask: (taskKey, taskProvider('data)) => unit = "";
699

7100
[@bs.module "react-native"] [@bs.scope "AppRegistry"]
8-
external registerHeadlessTask: (string, unit => task('data)) => unit = "";
101+
external startHeadlessTask: (taskId, taskKey, 'data) => unit = "";
9102

10103
// react-native-web
11104
type app = {

0 commit comments

Comments
 (0)