prostgles-client 4.0.221 → 4.0.223
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/index.js +1 -1
- package/dist/index.no-sync.js +1 -1
- package/dist/react-hooks.d.ts.map +1 -1
- package/dist/react-hooks.js +21 -11
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react-hooks.d.ts","sourceRoot":"","sources":["../lib/react-hooks.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,KAAK,mBAAmB,EAA8B,MAAM,iBAAiB,CAAC;AACvF,OAAO,KAAK,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACnE,KAAK,MAAM,GAAG,cAAc,OAAO,CAAC,CAAC;AASrC,eAAO,MAAM,QAAQ,gBAAiB,OAAO,KAAG,MAQ/C,CAAC;AAWF,eAAO,MAAM,KAAK,gEAOjB,CAAC;AAEF,eAAO,MAAM,qBAAqB,UAAW,GAAG,cAQ/C,CAAC;AAEF,eAAO,MAAM,WAAW,gCAGD,CAAC;AAExB,eAAO,MAAM,aAAa,kCAGD,CAAC;AAiB1B,KAAK,UAAU,GAAG,MAAM,OAAO,CAAC,IAAI,GAAG,CAAC,MAAM,IAAI,CAAC,CAAC,CAAC;AAErD;;;GAGG;AACH,eAAO,MAAM,mBAAmB,WAAY,UAAU,QAAQ,GAAG,EAAE,
|
|
1
|
+
{"version":3,"file":"react-hooks.d.ts","sourceRoot":"","sources":["../lib/react-hooks.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,KAAK,mBAAmB,EAA8B,MAAM,iBAAiB,CAAC;AACvF,OAAO,KAAK,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACnE,KAAK,MAAM,GAAG,cAAc,OAAO,CAAC,CAAC;AASrC,eAAO,MAAM,QAAQ,gBAAiB,OAAO,KAAG,MAQ/C,CAAC;AAWF,eAAO,MAAM,KAAK,g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F,eAAO,MAAM,oBAAoB,eAA0C,CAAC"}
|
package/dist/react-hooks.js
CHANGED
|
@@ -58,7 +58,6 @@ exports.useEffectDeep = ((callback, deps) => {
|
|
|
58
58
|
* Used to ensure subscriptions are always cleaned up
|
|
59
59
|
*/
|
|
60
60
|
const useAsyncEffectQueue = (effect, deps) => {
|
|
61
|
-
// const newEffect = { effect, deps, didCleanup: false }
|
|
62
61
|
const queue = useRef({
|
|
63
62
|
activeEffect: undefined,
|
|
64
63
|
newEffect: undefined,
|
|
@@ -81,13 +80,17 @@ const useAsyncEffectQueue = (effect, deps) => {
|
|
|
81
80
|
var _a, _b, _c, _d;
|
|
82
81
|
queue.current.newEffect = newEffect;
|
|
83
82
|
queue.current.history.push(newEffect);
|
|
84
|
-
/**
|
|
85
|
-
|
|
83
|
+
/**
|
|
84
|
+
* Await and cleanup previous effect
|
|
85
|
+
* Need to wait to ensure activeEffect cleanup finished
|
|
86
|
+
* */
|
|
86
87
|
await ((_d = (_c = (_b = (await ((_a = queue.current.activeEffect) === null || _a === void 0 ? void 0 : _a.resolvedCleanup))) === null || _b === void 0 ? void 0 : _b.run) === null || _c === void 0 ? void 0 : _c.call(_b)) === null || _d === void 0 ? void 0 : _d.catch(console.error));
|
|
87
88
|
queue.current.activeEffect = newEffect;
|
|
88
|
-
queue.current.
|
|
89
|
-
|
|
90
|
-
|
|
89
|
+
queue.current.newEffect = undefined;
|
|
90
|
+
/**
|
|
91
|
+
* Execute the new effect
|
|
92
|
+
*/
|
|
93
|
+
queue.current.activeEffect.resolvedCleanup = newEffect.effect().then((run) => ({ run }));
|
|
91
94
|
};
|
|
92
95
|
(0, exports.useEffectDeep)(() => {
|
|
93
96
|
const newEffect = { effect, deps, didCleanup: false };
|
|
@@ -199,28 +202,35 @@ exports.usePromise = usePromise;
|
|
|
199
202
|
const useSubscribe = (subFunc, expectsOne, filter, options, hookOptions) => {
|
|
200
203
|
const { skip } = hookOptions !== null && hookOptions !== void 0 ? hookOptions : {};
|
|
201
204
|
const defaultLoadingResult = { data: undefined, error: undefined, isLoading: true };
|
|
202
|
-
const [{ data,
|
|
205
|
+
const [{ data, isLoading, error }, setHookResult] = useState(defaultLoadingResult);
|
|
206
|
+
const hookResult = { data, isLoading, error };
|
|
207
|
+
const hookResultRef = useRef(hookResult);
|
|
208
|
+
hookResultRef.current = hookResult;
|
|
203
209
|
const getIsMounted = (0, exports.useIsMounted)();
|
|
204
210
|
(0, exports.useAsyncEffectQueue)(async () => {
|
|
205
211
|
if (!getIsMounted() || skip)
|
|
206
212
|
return;
|
|
207
|
-
|
|
213
|
+
if (!(0, prostgles_types_1.isEqual)(hookResultRef.current, defaultLoadingResult)) {
|
|
214
|
+
setHookResult(defaultLoadingResult);
|
|
215
|
+
}
|
|
208
216
|
const setError = (newError) => {
|
|
209
217
|
if (!getIsMounted())
|
|
210
218
|
return;
|
|
211
|
-
|
|
219
|
+
setHookResult({ data: undefined, error: newError, isLoading: false });
|
|
212
220
|
};
|
|
213
221
|
try {
|
|
214
222
|
const sub = await subFunc(filter, options, (newData) => {
|
|
215
223
|
if (!getIsMounted())
|
|
216
224
|
return;
|
|
217
|
-
|
|
225
|
+
setHookResult({
|
|
218
226
|
data: expectsOne ? newData[0] : newData,
|
|
219
227
|
error: undefined,
|
|
220
228
|
isLoading: false,
|
|
221
229
|
});
|
|
222
230
|
}, setError);
|
|
223
|
-
return
|
|
231
|
+
return () => {
|
|
232
|
+
sub.unsubscribe();
|
|
233
|
+
};
|
|
224
234
|
}
|
|
225
235
|
catch (error) {
|
|
226
236
|
setError(error);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "prostgles-client",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.223",
|
|
4
4
|
"description": "Reactive client for Postgres",
|
|
5
5
|
"main": "dist/prostgles-full.js",
|
|
6
6
|
"types": "dist/prostgles-full.d.ts",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"pushpublish": "npm version patch --git-tag-version false && git push && npm publish"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"prostgles-types": "^4.0.
|
|
31
|
+
"prostgles-types": "^4.0.160"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@types/node": "^14.14.14",
|