@applicaster/quick-brick-core 15.1.3-rc.0 → 15.1.4-alpha.7394150354
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/App/ActionSetters/index.ts +30 -15
- package/package.json +8 -8
|
@@ -20,10 +20,6 @@ const warnUndefinedContext = (context) =>
|
|
|
20
20
|
data: { context },
|
|
21
21
|
});
|
|
22
22
|
|
|
23
|
-
type Subscription = {
|
|
24
|
-
[x: string]: () => any;
|
|
25
|
-
};
|
|
26
|
-
|
|
27
23
|
const getModuleContext = R.path(["module", "context"]);
|
|
28
24
|
|
|
29
25
|
const getContexts = R.compose(
|
|
@@ -63,24 +59,43 @@ const useSubscribeToActionProviders = () => {
|
|
|
63
59
|
export const useRiverInitialState = () => {
|
|
64
60
|
const key = "getRiverInitialState";
|
|
65
61
|
const actionProvidersSubscriptions = useSubscribeToActionProviders();
|
|
62
|
+
// Capture river-init promises once. Re-calling getRiverInitialState() on every
|
|
63
|
+
// context re-render causes thrash and can drop already-completed observables.
|
|
64
|
+
const capturedPromisesRef = React.useRef<Promise<unknown>[] | null>(null);
|
|
66
65
|
|
|
67
|
-
|
|
68
|
-
|
|
66
|
+
if (
|
|
67
|
+
capturedPromisesRef.current === null &&
|
|
68
|
+
actionProvidersSubscriptions.length > 0
|
|
69
|
+
) {
|
|
70
|
+
const promises: Promise<unknown>[] = [];
|
|
71
|
+
let hasRiverInitMethod = false;
|
|
72
|
+
|
|
73
|
+
for (const item of actionProvidersSubscriptions) {
|
|
74
|
+
if (!item?.[key]) continue;
|
|
69
75
|
|
|
70
|
-
|
|
71
|
-
const
|
|
76
|
+
hasRiverInitMethod = true;
|
|
77
|
+
const promise = item[key]();
|
|
72
78
|
|
|
73
|
-
if (
|
|
74
|
-
|
|
79
|
+
if (promise) {
|
|
80
|
+
promises.push(promise);
|
|
75
81
|
}
|
|
82
|
+
}
|
|
76
83
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
84
|
+
// Lock when we have promises, or when no provider exposes river-init.
|
|
85
|
+
// If methods exist but all returned undefined (observable not created yet),
|
|
86
|
+
// keep null and retry on next render.
|
|
87
|
+
if (promises.length > 0 || !hasRiverInitMethod) {
|
|
88
|
+
capturedPromisesRef.current = promises;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
80
91
|
|
|
81
|
-
if (!actionProvidersSubscriptions.length)
|
|
92
|
+
if (!actionProvidersSubscriptions.length) {
|
|
93
|
+
return undefined;
|
|
94
|
+
}
|
|
82
95
|
|
|
83
|
-
return
|
|
96
|
+
return capturedPromisesRef.current === null
|
|
97
|
+
? undefined
|
|
98
|
+
: capturedPromisesRef.current;
|
|
84
99
|
};
|
|
85
100
|
|
|
86
101
|
const getActionInitialStateSetters = (key) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@applicaster/quick-brick-core",
|
|
3
|
-
"version": "15.1.
|
|
3
|
+
"version": "15.1.4-alpha.7394150354",
|
|
4
4
|
"description": "Core package for Applicaster's Quick Brick App",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -28,13 +28,13 @@
|
|
|
28
28
|
},
|
|
29
29
|
"homepage": "https://github.com/applicaster/quickbrick#readme",
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@applicaster/applicaster-types": "15.1.
|
|
32
|
-
"@applicaster/quick-brick-core-plugins": "15.1.
|
|
33
|
-
"@applicaster/zapp-pipes-v2-client": "15.1.
|
|
34
|
-
"@applicaster/zapp-react-native-bridge": "15.1.
|
|
35
|
-
"@applicaster/zapp-react-native-redux": "15.1.
|
|
36
|
-
"@applicaster/zapp-react-native-ui-components": "15.1.
|
|
37
|
-
"@applicaster/zapp-react-native-utils": "15.1.
|
|
31
|
+
"@applicaster/applicaster-types": "15.1.4-alpha.7394150354",
|
|
32
|
+
"@applicaster/quick-brick-core-plugins": "15.1.4-alpha.7394150354",
|
|
33
|
+
"@applicaster/zapp-pipes-v2-client": "15.1.4-alpha.7394150354",
|
|
34
|
+
"@applicaster/zapp-react-native-bridge": "15.1.4-alpha.7394150354",
|
|
35
|
+
"@applicaster/zapp-react-native-redux": "15.1.4-alpha.7394150354",
|
|
36
|
+
"@applicaster/zapp-react-native-ui-components": "15.1.4-alpha.7394150354",
|
|
37
|
+
"@applicaster/zapp-react-native-utils": "15.1.4-alpha.7394150354",
|
|
38
38
|
"atob": "^2.1.2",
|
|
39
39
|
"axios": "^0.28.0",
|
|
40
40
|
"btoa": "^1.2.1",
|