@koolbase/core 12.42.0 → 12.43.0
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/dist/cjs/flags.d.ts +7 -0
- package/dist/cjs/flags.js +18 -0
- package/dist/esm/flags.d.ts +7 -0
- package/dist/esm/flags.js +18 -0
- package/package.json +1 -1
package/dist/cjs/flags.d.ts
CHANGED
|
@@ -5,8 +5,15 @@ export declare class KoolbaseFlags {
|
|
|
5
5
|
private deviceId;
|
|
6
6
|
private lastArgs;
|
|
7
7
|
private inFlight;
|
|
8
|
+
private listeners;
|
|
8
9
|
constructor(config: KoolbaseConfig, deviceId: string);
|
|
9
10
|
koolbaseFetch(appVersion: string, platform: string): Promise<void>;
|
|
11
|
+
/**
|
|
12
|
+
* Calls [listener] each time a bootstrap brings flags and config (the first
|
|
13
|
+
* load and every refresh). Returns the function that stops it. A listener
|
|
14
|
+
* that throws never stops the others.
|
|
15
|
+
*/
|
|
16
|
+
subscribe(listener: () => void): () => void;
|
|
10
17
|
/**
|
|
11
18
|
* The project id learned from the bootstrap payload, or '' while the first
|
|
12
19
|
* bootstrap has not completed (storage's publicUrlFor reads it).
|
package/dist/cjs/flags.js
CHANGED
|
@@ -9,6 +9,9 @@ class KoolbaseFlags {
|
|
|
9
9
|
// and the fetch in flight, so nudges never stack.
|
|
10
10
|
this.lastArgs = null;
|
|
11
11
|
this.inFlight = null;
|
|
12
|
+
// Told when a bootstrap brings new flags or config (onRemoteChange), so a
|
|
13
|
+
// screen that reads them can draw again once they arrive.
|
|
14
|
+
this.listeners = new Set();
|
|
12
15
|
this.config = config;
|
|
13
16
|
this.deviceId = deviceId;
|
|
14
17
|
}
|
|
@@ -18,10 +21,25 @@ class KoolbaseFlags {
|
|
|
18
21
|
const res = await (0, network_js_1.koolbaseFetch)(`${this.config.baseUrl}/v1/bootstrap?public_key=${this.config.publicKey}&device_id=${this.deviceId}&app_version=${appVersion}&platform=${platform}`);
|
|
19
22
|
if (res.ok) {
|
|
20
23
|
this.payload = await res.json();
|
|
24
|
+
for (const l of [...this.listeners]) {
|
|
25
|
+
try {
|
|
26
|
+
l();
|
|
27
|
+
}
|
|
28
|
+
catch (_) { /* a listener's error is its own */ }
|
|
29
|
+
}
|
|
21
30
|
}
|
|
22
31
|
}
|
|
23
32
|
catch (_) { }
|
|
24
33
|
}
|
|
34
|
+
/**
|
|
35
|
+
* Calls [listener] each time a bootstrap brings flags and config (the first
|
|
36
|
+
* load and every refresh). Returns the function that stops it. A listener
|
|
37
|
+
* that throws never stops the others.
|
|
38
|
+
*/
|
|
39
|
+
subscribe(listener) {
|
|
40
|
+
this.listeners.add(listener);
|
|
41
|
+
return () => { this.listeners.delete(listener); };
|
|
42
|
+
}
|
|
25
43
|
/**
|
|
26
44
|
* The project id learned from the bootstrap payload, or '' while the first
|
|
27
45
|
* bootstrap has not completed (storage's publicUrlFor reads it).
|
package/dist/esm/flags.d.ts
CHANGED
|
@@ -5,8 +5,15 @@ export declare class KoolbaseFlags {
|
|
|
5
5
|
private deviceId;
|
|
6
6
|
private lastArgs;
|
|
7
7
|
private inFlight;
|
|
8
|
+
private listeners;
|
|
8
9
|
constructor(config: KoolbaseConfig, deviceId: string);
|
|
9
10
|
koolbaseFetch(appVersion: string, platform: string): Promise<void>;
|
|
11
|
+
/**
|
|
12
|
+
* Calls [listener] each time a bootstrap brings flags and config (the first
|
|
13
|
+
* load and every refresh). Returns the function that stops it. A listener
|
|
14
|
+
* that throws never stops the others.
|
|
15
|
+
*/
|
|
16
|
+
subscribe(listener: () => void): () => void;
|
|
10
17
|
/**
|
|
11
18
|
* The project id learned from the bootstrap payload, or '' while the first
|
|
12
19
|
* bootstrap has not completed (storage's publicUrlFor reads it).
|
package/dist/esm/flags.js
CHANGED
|
@@ -6,6 +6,9 @@ export class KoolbaseFlags {
|
|
|
6
6
|
// and the fetch in flight, so nudges never stack.
|
|
7
7
|
this.lastArgs = null;
|
|
8
8
|
this.inFlight = null;
|
|
9
|
+
// Told when a bootstrap brings new flags or config (onRemoteChange), so a
|
|
10
|
+
// screen that reads them can draw again once they arrive.
|
|
11
|
+
this.listeners = new Set();
|
|
9
12
|
this.config = config;
|
|
10
13
|
this.deviceId = deviceId;
|
|
11
14
|
}
|
|
@@ -15,10 +18,25 @@ export class KoolbaseFlags {
|
|
|
15
18
|
const res = await koolbaseFetch(`${this.config.baseUrl}/v1/bootstrap?public_key=${this.config.publicKey}&device_id=${this.deviceId}&app_version=${appVersion}&platform=${platform}`);
|
|
16
19
|
if (res.ok) {
|
|
17
20
|
this.payload = await res.json();
|
|
21
|
+
for (const l of [...this.listeners]) {
|
|
22
|
+
try {
|
|
23
|
+
l();
|
|
24
|
+
}
|
|
25
|
+
catch (_) { /* a listener's error is its own */ }
|
|
26
|
+
}
|
|
18
27
|
}
|
|
19
28
|
}
|
|
20
29
|
catch (_) { }
|
|
21
30
|
}
|
|
31
|
+
/**
|
|
32
|
+
* Calls [listener] each time a bootstrap brings flags and config (the first
|
|
33
|
+
* load and every refresh). Returns the function that stops it. A listener
|
|
34
|
+
* that throws never stops the others.
|
|
35
|
+
*/
|
|
36
|
+
subscribe(listener) {
|
|
37
|
+
this.listeners.add(listener);
|
|
38
|
+
return () => { this.listeners.delete(listener); };
|
|
39
|
+
}
|
|
22
40
|
/**
|
|
23
41
|
* The project id learned from the bootstrap payload, or '' while the first
|
|
24
42
|
* bootstrap has not completed (storage's publicUrlFor reads it).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@koolbase/core",
|
|
3
|
-
"version": "12.
|
|
3
|
+
"version": "12.43.0",
|
|
4
4
|
"description": "Koolbase SDK core \u2014 shared behaviour behind @koolbase/react-native and @koolbase/js. Install one of those, not this.",
|
|
5
5
|
"main": "./dist/cjs/index.js",
|
|
6
6
|
"types": "./dist/esm/index.d.ts",
|