prostgles-client 4.0.273 → 4.0.275
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAsyncEffectQueue.d.ts","sourceRoot":"","sources":["../../lib/hooks/useAsyncEffectQueue.ts"],"names":[],"mappings":"AAKA,KAAK,UAAU,GAAG,MAAM,OAAO,CAAC,IAAI,GAAG,CAAC,MAAM,IAAI,CAAC,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"useAsyncEffectQueue.d.ts","sourceRoot":"","sources":["../../lib/hooks/useAsyncEffectQueue.ts"],"names":[],"mappings":"AAKA,KAAK,UAAU,GAAG,MAAM,OAAO,CAAC,IAAI,GAAG,CAAC,MAAM,IAAI,CAAC,CAAC,CAAC;AAQrD;;;GAGG;AACH,eAAO,MAAM,mBAAmB,WAAY,UAAU,QAAQ,GAAG,EAAE,SAmDlE,CAAC"}
|
|
@@ -9,10 +9,11 @@ const reactImports_1 = require("./reactImports");
|
|
|
9
9
|
*/
|
|
10
10
|
const useAsyncEffectQueue = (effect, deps) => {
|
|
11
11
|
const idRef = (0, reactImports_1.useRef)(0);
|
|
12
|
+
const isMounted = (0, reactImports_1.useRef)(true);
|
|
12
13
|
const newEffect = (0, reactImports_1.useRef)();
|
|
13
14
|
const activeEffect = (0, reactImports_1.useRef)();
|
|
14
15
|
const onRender = async () => {
|
|
15
|
-
var _a;
|
|
16
|
+
var _a, _b;
|
|
16
17
|
/**
|
|
17
18
|
* Await and cleanup previous effect
|
|
18
19
|
* */
|
|
@@ -20,12 +21,12 @@ const useAsyncEffectQueue = (effect, deps) => {
|
|
|
20
21
|
const { cleanup, effect, id } = activeEffect.current;
|
|
21
22
|
activeEffect.current = { id, state: "cleaning", effect };
|
|
22
23
|
await cleanup().catch(console.error);
|
|
23
|
-
activeEffect.current =
|
|
24
|
+
activeEffect.current = { id, state: "cleaned", effect };
|
|
24
25
|
}
|
|
25
26
|
/**
|
|
26
27
|
* Start new effect
|
|
27
28
|
*/
|
|
28
|
-
if (newEffect.current &&
|
|
29
|
+
if (newEffect.current && ((_b = activeEffect.current) === null || _b === void 0 ? void 0 : _b.effect) !== newEffect.current.effect) {
|
|
29
30
|
const currentEffect = newEffect.current;
|
|
30
31
|
const { effect, id } = currentEffect;
|
|
31
32
|
activeEffect.current = { id, state: "resolving", effect };
|
|
@@ -41,15 +42,17 @@ const useAsyncEffectQueue = (effect, deps) => {
|
|
|
41
42
|
return async () => { };
|
|
42
43
|
});
|
|
43
44
|
activeEffect.current = { id, state: "resolved", effect, cleanup };
|
|
44
|
-
if (currentEffect !== newEffect.current) {
|
|
45
|
+
if (!isMounted.current || currentEffect !== newEffect.current) {
|
|
45
46
|
onRender();
|
|
46
47
|
}
|
|
47
48
|
}
|
|
48
49
|
};
|
|
49
50
|
(0, useEffectDeep_1.useEffectDeep)(() => {
|
|
51
|
+
isMounted.current = true;
|
|
50
52
|
newEffect.current = { effect, deps, id: ++idRef.current };
|
|
51
53
|
onRender();
|
|
52
54
|
return () => {
|
|
55
|
+
isMounted.current = false;
|
|
53
56
|
onRender();
|
|
54
57
|
};
|
|
55
58
|
}, deps);
|