prostgles-client 4.0.265 → 4.0.267
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/getDbHandler.d.ts.map +1 -1
- package/dist/getDbHandler.js +5 -4
- package/dist/hooks/reactImports.d.ts +1 -0
- package/dist/hooks/reactImports.d.ts.map +1 -1
- package/dist/hooks/reactImports.js +3 -1
- package/dist/hooks/useAsyncEffectQueue.d.ts +8 -0
- package/dist/hooks/useAsyncEffectQueue.d.ts.map +1 -0
- package/dist/hooks/useAsyncEffectQueue.js +57 -0
- package/dist/hooks/useEffectAsync.d.ts +2 -0
- package/dist/hooks/useEffectAsync.d.ts.map +1 -0
- package/dist/hooks/useEffectAsync.js +30 -0
- package/dist/hooks/useEffectDeep.d.ts +5 -0
- package/dist/hooks/useEffectDeep.d.ts.map +1 -0
- package/dist/hooks/useEffectDeep.js +21 -0
- package/dist/hooks/useFetch.d.ts +7 -0
- package/dist/hooks/useFetch.d.ts.map +1 -0
- package/dist/hooks/useFetch.js +30 -0
- package/dist/hooks/useIsMounted.d.ts +2 -0
- package/dist/hooks/useIsMounted.d.ts.map +1 -0
- package/dist/hooks/useIsMounted.js +17 -0
- package/dist/hooks/usePromise.d.ts +5 -0
- package/dist/hooks/usePromise.d.ts.map +1 -0
- package/dist/hooks/usePromise.js +67 -0
- package/dist/hooks/useProstglesClient.d.ts +1 -0
- package/dist/hooks/useProstglesClient.d.ts.map +1 -1
- package/dist/hooks/useProstglesClient.js +18 -5
- package/dist/hooks/useSubscribe.d.ts +1 -1
- package/dist/hooks/useSubscribe.d.ts.map +1 -1
- package/dist/hooks/useSubscribe.js +4 -3
- package/dist/hooks/useSync.d.ts +20 -0
- package/dist/hooks/useSync.d.ts.map +1 -0
- package/dist/hooks/useSync.js +34 -0
- package/dist/index.js +1 -1
- package/dist/index.no-sync.js +1 -1
- package/dist/prostgles-full.d.ts +12 -4
- package/dist/prostgles-full.d.ts.map +1 -1
- package/dist/prostgles-full.js +27 -2
- package/dist/prostgles.d.ts +1 -1
- package/dist/prostgles.d.ts.map +1 -1
- package/dist/prostgles.js +1 -1
- package/package.json +1 -1
- package/dist/hooks/react-hooks.d.ts +0 -43
- package/dist/hooks/react-hooks.d.ts.map +0 -1
- package/dist/hooks/react-hooks.js +0 -237
package/dist/prostgles-full.d.ts
CHANGED
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
import type { UserLike } from "prostgles-types";
|
|
2
2
|
import { type InitOptions } from "./prostgles";
|
|
3
|
+
import { SyncedTable } from "./SyncedTable/SyncedTable";
|
|
3
4
|
declare function prostgles<DBSchema = void, U extends UserLike = UserLike>(params: InitOptions<DBSchema, U>): Promise<unknown>;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export
|
|
5
|
+
export { SyncedTable };
|
|
6
|
+
export * from "./hooks/useSync";
|
|
7
|
+
export * from "./hooks/useSubscribe";
|
|
8
|
+
export * from "./hooks/useProstglesClient";
|
|
9
|
+
export * from "./hooks/usePromise";
|
|
10
|
+
export * from "./hooks/useIsMounted";
|
|
11
|
+
export * from "./hooks/useFetch";
|
|
12
|
+
export * from "./hooks/useEffectDeep";
|
|
13
|
+
export * from "./hooks/useEffectAsync";
|
|
14
|
+
export * from "./hooks/useAsyncEffectQueue";
|
|
15
|
+
export default prostgles;
|
|
8
16
|
//# sourceMappingURL=prostgles-full.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prostgles-full.d.ts","sourceRoot":"","sources":["../lib/prostgles-full.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAqB,KAAK,WAAW,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"prostgles-full.d.ts","sourceRoot":"","sources":["../lib/prostgles-full.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAqB,KAAK,WAAW,EAAE,MAAM,aAAa,CAAC;AAClE,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAExD,iBAAS,SAAS,CAAC,QAAQ,GAAG,IAAI,EAAE,CAAC,SAAS,QAAQ,GAAG,QAAQ,EAC/D,MAAM,EAAE,WAAW,CAAC,QAAQ,EAAE,CAAC,CAAC,oBAGjC;AAED,OAAO,EAAE,WAAW,EAAE,CAAC;AACvB,cAAc,iBAAiB,CAAC;AAChC,cAAc,sBAAsB,CAAC;AACrC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,6BAA6B,CAAC;AAC5C,eAAe,SAAS,CAAC"}
|
package/dist/prostgles-full.js
CHANGED
|
@@ -1,8 +1,33 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.SyncedTable = void 0;
|
|
2
18
|
const prostgles_1 = require("./prostgles");
|
|
3
19
|
const SyncedTable_1 = require("./SyncedTable/SyncedTable");
|
|
20
|
+
Object.defineProperty(exports, "SyncedTable", { enumerable: true, get: function () { return SyncedTable_1.SyncedTable; } });
|
|
4
21
|
function prostgles(params) {
|
|
5
22
|
return (0, prostgles_1.prostgles)(params, SyncedTable_1.SyncedTable);
|
|
6
23
|
}
|
|
7
|
-
|
|
8
|
-
|
|
24
|
+
__exportStar(require("./hooks/useSync"), exports);
|
|
25
|
+
__exportStar(require("./hooks/useSubscribe"), exports);
|
|
26
|
+
__exportStar(require("./hooks/useProstglesClient"), exports);
|
|
27
|
+
__exportStar(require("./hooks/usePromise"), exports);
|
|
28
|
+
__exportStar(require("./hooks/useIsMounted"), exports);
|
|
29
|
+
__exportStar(require("./hooks/useFetch"), exports);
|
|
30
|
+
__exportStar(require("./hooks/useEffectDeep"), exports);
|
|
31
|
+
__exportStar(require("./hooks/useEffectAsync"), exports);
|
|
32
|
+
__exportStar(require("./hooks/useAsyncEffectQueue"), exports);
|
|
33
|
+
exports.default = prostgles;
|
package/dist/prostgles.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ import type { Sync, SyncDataItem, SyncOne, SyncOneOptions, SyncOptions, SyncedTa
|
|
|
6
6
|
import type { Socket } from "socket.io-client";
|
|
7
7
|
export declare const isClientSide: boolean;
|
|
8
8
|
export declare const debug: any;
|
|
9
|
-
export * from "./hooks/
|
|
9
|
+
export * from "./hooks/useEffectDeep";
|
|
10
10
|
export * from "./hooks/useProstglesClient";
|
|
11
11
|
export { MethodHandler, SQLResult, asName };
|
|
12
12
|
/**
|
package/dist/prostgles.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prostgles.d.ts","sourceRoot":"","sources":["../lib/prostgles.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,SAAS,EACT,YAAY,EACZ,iBAAiB,EACjB,QAAQ,EACR,aAAa,EACb,WAAW,EAC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AAE,OAAO,WAAW,GAAG,SAAS,oBAmI5C"}
|
package/dist/prostgles.js
CHANGED
|
@@ -35,7 +35,7 @@ const debug = function (...args) {
|
|
|
35
35
|
}
|
|
36
36
|
};
|
|
37
37
|
exports.debug = debug;
|
|
38
|
-
__exportStar(require("./hooks/
|
|
38
|
+
__exportStar(require("./hooks/useEffectDeep"), exports);
|
|
39
39
|
__exportStar(require("./hooks/useProstglesClient"), exports);
|
|
40
40
|
function prostgles(initOpts, syncedTable) {
|
|
41
41
|
const { socket, onReady, onDisconnect, onReconnect, onSchemaChange, onReload, onDebug } = initOpts;
|
package/package.json
CHANGED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import type { HookOptions, TableHandlerClient } from "../prostgles";
|
|
3
|
-
export declare const getIO: (throwError?: boolean) => typeof import("socket.io-client").io;
|
|
4
|
-
export declare const useDeepCompareMemoize: (value: unknown) => unknown;
|
|
5
|
-
export declare const useMemoDeep: typeof import("react").useMemo;
|
|
6
|
-
export declare const useEffectDeep: typeof import("react").useEffect;
|
|
7
|
-
type EffectFunc = () => Promise<void | (() => void)>;
|
|
8
|
-
/**
|
|
9
|
-
* Debounce with execute first
|
|
10
|
-
* Used to ensure subscriptions are always cleaned up
|
|
11
|
-
*/
|
|
12
|
-
export declare const useAsyncEffectQueue: (effect: EffectFunc, deps: any[]) => void;
|
|
13
|
-
export declare const useEffectAsync: (effect: () => Promise<void | (() => void)>, inputs: any[]) => void;
|
|
14
|
-
export declare const useIsMounted: () => () => boolean;
|
|
15
|
-
type PromiseFunc = () => Promise<any>;
|
|
16
|
-
type NamedResult = Record<string, PromiseFunc>;
|
|
17
|
-
export declare const usePromise: <F extends PromiseFunc | NamedResult>(f: F, deps?: any[]) => F extends NamedResult ? { [key in keyof F]: Awaited<ReturnType<F[key]>>; } : F extends PromiseFunc ? Awaited<ReturnType<F>> | undefined : undefined;
|
|
18
|
-
export type DataFetchHookResult = {
|
|
19
|
-
data: any;
|
|
20
|
-
error?: undefined;
|
|
21
|
-
isLoading: false;
|
|
22
|
-
} | {
|
|
23
|
-
data?: undefined;
|
|
24
|
-
error: any;
|
|
25
|
-
isLoading: false;
|
|
26
|
-
} | {
|
|
27
|
-
data?: undefined;
|
|
28
|
-
error?: undefined;
|
|
29
|
-
isLoading: true;
|
|
30
|
-
};
|
|
31
|
-
export declare const useSync: (syncFunc: Required<TableHandlerClient>["sync"] | Required<TableHandlerClient>["syncOne"], basicFilter: Parameters<Required<TableHandlerClient>["sync"]>[0], syncOptions: Parameters<Required<TableHandlerClient>["sync"]>[1], hookOptions?: HookOptions) => {
|
|
32
|
-
data: any;
|
|
33
|
-
error: any;
|
|
34
|
-
isLoading: boolean;
|
|
35
|
-
};
|
|
36
|
-
export declare const useFetch: (fetchFunc: (...args: any) => Promise<any>, args?: any[], hookOptions?: HookOptions) => {
|
|
37
|
-
data: any;
|
|
38
|
-
error: any;
|
|
39
|
-
isLoading: boolean;
|
|
40
|
-
};
|
|
41
|
-
export declare const __prglReactInstalled: () => boolean;
|
|
42
|
-
export {};
|
|
43
|
-
//# sourceMappingURL=react-hooks.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"react-hooks.d.ts","sourceRoot":"","sources":["../../lib/hooks/react-hooks.ts"],"names":[],"mappings":";AACA,OAAO,KAAK,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAIpE,eAAO,MAAM,KAAK,gEAQjB,CAAC;AAEF,eAAO,MAAM,qBAAqB,UAAW,OAAO,YAQnD,CAAC;AAEF,eAAO,MAAM,WAAW,gCAGD,CAAC;AAExB,eAAO,MAAM,aAAa,kCAGD,CAAC;AAI1B,KAAK,UAAU,GAAG,MAAM,OAAO,CAAC,IAAI,GAAG,CAAC,MAAM,IAAI,CAAC,CAAC,CAAC;AAOrD;;;GAGG;AACH,eAAO,MAAM,mBAAmB,WAAY,UAAU,QAAQ,GAAG,EAAE,SAgDlE,CAAC;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ule", { value: true });
|
|
3
|
-
exports.__prglReactInstalled = exports.useFetch = exports.useSync = exports.usePromise = exports.useIsMounted = exports.useEffectAsync = exports.useAsyncEffectQueue = exports.useEffectDeep = exports.useMemoDeep = exports.useDeepCompareMemoize = exports.getIO = void 0;
|
|
4
|
-
const prostgles_types_1 = require("prostgles-types");
|
|
5
|
-
const reactImports_1 = require("./reactImports");
|
|
6
|
-
const getIO = (throwError = false) => {
|
|
7
|
-
try {
|
|
8
|
-
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
9
|
-
const io = require("socket.io-client");
|
|
10
|
-
return io;
|
|
11
|
-
}
|
|
12
|
-
catch (err) { }
|
|
13
|
-
if (throwError)
|
|
14
|
-
throw new Error("Must install socket.io-client");
|
|
15
|
-
return {};
|
|
16
|
-
};
|
|
17
|
-
exports.getIO = getIO;
|
|
18
|
-
const useDeepCompareMemoize = (value) => {
|
|
19
|
-
const ref = (0, reactImports_1.useRef)();
|
|
20
|
-
if (!(0, prostgles_types_1.isEqual)(value, ref.current)) {
|
|
21
|
-
ref.current = value;
|
|
22
|
-
}
|
|
23
|
-
return ref.current;
|
|
24
|
-
};
|
|
25
|
-
exports.useDeepCompareMemoize = useDeepCompareMemoize;
|
|
26
|
-
exports.useMemoDeep = ((callback, deps) => {
|
|
27
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
28
|
-
return reactImports_1.React.useMemo(callback, deps === null || deps === void 0 ? void 0 : deps.map(exports.useDeepCompareMemoize));
|
|
29
|
-
});
|
|
30
|
-
exports.useEffectDeep = ((callback, deps) => {
|
|
31
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
32
|
-
(0, reactImports_1.useEffect)(callback, deps === null || deps === void 0 ? void 0 : deps.map(exports.useDeepCompareMemoize));
|
|
33
|
-
});
|
|
34
|
-
/**
|
|
35
|
-
* Debounce with execute first
|
|
36
|
-
* Used to ensure subscriptions are always cleaned up
|
|
37
|
-
*/
|
|
38
|
-
const useAsyncEffectQueue = (effect, deps) => {
|
|
39
|
-
const newEffect = (0, reactImports_1.useRef)();
|
|
40
|
-
const activeEffect = (0, reactImports_1.useRef)();
|
|
41
|
-
const onRender = async () => {
|
|
42
|
-
var _a;
|
|
43
|
-
/**
|
|
44
|
-
* Await and cleanup previous effect
|
|
45
|
-
* */
|
|
46
|
-
if (((_a = activeEffect.current) === null || _a === void 0 ? void 0 : _a.state) === "resolved") {
|
|
47
|
-
const { cleanup, effect } = activeEffect.current;
|
|
48
|
-
activeEffect.current = { state: "cleaning", effect };
|
|
49
|
-
await cleanup().catch(console.error);
|
|
50
|
-
activeEffect.current = undefined;
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Start new effect
|
|
54
|
-
*/
|
|
55
|
-
if (newEffect.current && !activeEffect.current) {
|
|
56
|
-
const currentEffect = newEffect.current;
|
|
57
|
-
const { effect } = currentEffect;
|
|
58
|
-
activeEffect.current = { state: "resolving", effect };
|
|
59
|
-
const cleanup = await effect()
|
|
60
|
-
.then((run) => {
|
|
61
|
-
/* Wrapped in a promise to ensure cleanup is awaited */
|
|
62
|
-
return async () => {
|
|
63
|
-
await (run === null || run === void 0 ? void 0 : run());
|
|
64
|
-
};
|
|
65
|
-
})
|
|
66
|
-
.catch((e) => {
|
|
67
|
-
console.error(e);
|
|
68
|
-
return async () => { };
|
|
69
|
-
});
|
|
70
|
-
activeEffect.current = { state: "resolved", effect, cleanup };
|
|
71
|
-
if (currentEffect !== newEffect.current) {
|
|
72
|
-
onRender();
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
(0, exports.useEffectDeep)(() => {
|
|
77
|
-
newEffect.current = { effect, deps };
|
|
78
|
-
onRender();
|
|
79
|
-
return () => {
|
|
80
|
-
newEffect.current = undefined;
|
|
81
|
-
onRender();
|
|
82
|
-
};
|
|
83
|
-
}, deps);
|
|
84
|
-
};
|
|
85
|
-
exports.useAsyncEffectQueue = useAsyncEffectQueue;
|
|
86
|
-
const useEffectAsync = (effect, inputs) => {
|
|
87
|
-
const onCleanup = (0, reactImports_1.useRef)({
|
|
88
|
-
cleanup: undefined,
|
|
89
|
-
effect,
|
|
90
|
-
cleanupEffect: undefined,
|
|
91
|
-
});
|
|
92
|
-
onCleanup.current.effect = effect;
|
|
93
|
-
(0, exports.useEffectDeep)(() => {
|
|
94
|
-
effect().then((result) => {
|
|
95
|
-
if (typeof result === "function") {
|
|
96
|
-
onCleanup.current.cleanup = result;
|
|
97
|
-
if (onCleanup.current.cleanupEffect === effect) {
|
|
98
|
-
result();
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
});
|
|
102
|
-
return () => {
|
|
103
|
-
var _a, _b;
|
|
104
|
-
onCleanup.current.cleanupEffect = effect;
|
|
105
|
-
(_b = (_a = onCleanup.current).cleanup) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
106
|
-
};
|
|
107
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
108
|
-
}, inputs);
|
|
109
|
-
};
|
|
110
|
-
exports.useEffectAsync = useEffectAsync;
|
|
111
|
-
const useIsMounted = () => {
|
|
112
|
-
const isMountedRef = (0, reactImports_1.useRef)(true);
|
|
113
|
-
const isMounted = (0, reactImports_1.useCallback)(() => isMountedRef.current, []);
|
|
114
|
-
(0, reactImports_1.useEffect)(() => {
|
|
115
|
-
/** React 18 Strict Mode fix (new strict mode restores the previous state on the second mount) */
|
|
116
|
-
isMountedRef.current = true;
|
|
117
|
-
return () => {
|
|
118
|
-
isMountedRef.current = false;
|
|
119
|
-
};
|
|
120
|
-
}, []);
|
|
121
|
-
return isMounted;
|
|
122
|
-
};
|
|
123
|
-
exports.useIsMounted = useIsMounted;
|
|
124
|
-
const usePromise = (f, deps = []) => {
|
|
125
|
-
const isPromiseFunc = (val) => {
|
|
126
|
-
try {
|
|
127
|
-
return typeof val === "function" || val instanceof Promise;
|
|
128
|
-
}
|
|
129
|
-
catch (e) {
|
|
130
|
-
console.error(e);
|
|
131
|
-
}
|
|
132
|
-
return false;
|
|
133
|
-
};
|
|
134
|
-
const isNamedObj = (val) => {
|
|
135
|
-
try {
|
|
136
|
-
return (0, prostgles_types_1.isObject)(val) && !isPromiseFunc(val);
|
|
137
|
-
}
|
|
138
|
-
catch (e) {
|
|
139
|
-
console.error(e);
|
|
140
|
-
}
|
|
141
|
-
return false;
|
|
142
|
-
};
|
|
143
|
-
const getNamedObjResults = async (val) => {
|
|
144
|
-
const data = {};
|
|
145
|
-
const keys = (0, prostgles_types_1.getKeys)(val);
|
|
146
|
-
for await (const key of keys) {
|
|
147
|
-
const prop = val[key];
|
|
148
|
-
try {
|
|
149
|
-
data[key] = typeof prop === "function" ? await prop() : await prop;
|
|
150
|
-
}
|
|
151
|
-
catch (e) {
|
|
152
|
-
console.error(e);
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
return data;
|
|
156
|
-
};
|
|
157
|
-
const [result, setResult] = (0, reactImports_1.useState)(isNamedObj(f) ? {} : undefined);
|
|
158
|
-
const getIsMounted = (0, exports.useIsMounted)();
|
|
159
|
-
(0, exports.useAsyncEffectQueue)(async () => {
|
|
160
|
-
let promiseResult;
|
|
161
|
-
try {
|
|
162
|
-
if (isNamedObj(f)) {
|
|
163
|
-
promiseResult = await getNamedObjResults(f);
|
|
164
|
-
}
|
|
165
|
-
else {
|
|
166
|
-
const funcRes = await f();
|
|
167
|
-
const isNObj = isNamedObj(funcRes);
|
|
168
|
-
promiseResult =
|
|
169
|
-
isNObj ? await getNamedObjResults(funcRes)
|
|
170
|
-
: isPromiseFunc(funcRes) ? await funcRes()
|
|
171
|
-
: funcRes;
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
catch (e) {
|
|
175
|
-
console.error(e);
|
|
176
|
-
}
|
|
177
|
-
if (!getIsMounted())
|
|
178
|
-
return;
|
|
179
|
-
setResult(promiseResult);
|
|
180
|
-
}, deps);
|
|
181
|
-
return result;
|
|
182
|
-
};
|
|
183
|
-
exports.usePromise = usePromise;
|
|
184
|
-
const useSync = (syncFunc, basicFilter, syncOptions, hookOptions) => {
|
|
185
|
-
const { skip } = hookOptions !== null && hookOptions !== void 0 ? hookOptions : {};
|
|
186
|
-
const defaultLoadingResult = { data: undefined, error: undefined, isLoading: true };
|
|
187
|
-
const [{ data, error, isLoading }, setResult] = (0, reactImports_1.useState)(defaultLoadingResult);
|
|
188
|
-
const getIsMounted = (0, exports.useIsMounted)();
|
|
189
|
-
(0, exports.useAsyncEffectQueue)(async () => {
|
|
190
|
-
if (!getIsMounted() || skip)
|
|
191
|
-
return;
|
|
192
|
-
const setError = (newError) => {
|
|
193
|
-
if (!getIsMounted())
|
|
194
|
-
return;
|
|
195
|
-
setResult({ data: undefined, error: newError, isLoading: false });
|
|
196
|
-
};
|
|
197
|
-
try {
|
|
198
|
-
const syncHandlers = await syncFunc(basicFilter, syncOptions, (newData) => {
|
|
199
|
-
if (!getIsMounted())
|
|
200
|
-
return;
|
|
201
|
-
setResult({ data: newData, error: undefined, isLoading: false });
|
|
202
|
-
}, setError);
|
|
203
|
-
return syncHandlers.$unsync;
|
|
204
|
-
}
|
|
205
|
-
catch (error) {
|
|
206
|
-
setError(error);
|
|
207
|
-
}
|
|
208
|
-
}, [syncFunc, basicFilter, syncOptions, skip]);
|
|
209
|
-
return { data, error, isLoading };
|
|
210
|
-
};
|
|
211
|
-
exports.useSync = useSync;
|
|
212
|
-
const useFetch = (fetchFunc, args = [], hookOptions) => {
|
|
213
|
-
const { skip, deps = [] } = hookOptions !== null && hookOptions !== void 0 ? hookOptions : {};
|
|
214
|
-
const defaultLoadingResult = { data: undefined, error: undefined, isLoading: true };
|
|
215
|
-
const [{ data, error, isLoading }, setResult] = (0, reactImports_1.useState)(defaultLoadingResult);
|
|
216
|
-
const getIsMounted = (0, exports.useIsMounted)();
|
|
217
|
-
(0, exports.useAsyncEffectQueue)(async () => {
|
|
218
|
-
if (!getIsMounted() || skip)
|
|
219
|
-
return;
|
|
220
|
-
setResult(defaultLoadingResult);
|
|
221
|
-
try {
|
|
222
|
-
const newData = await fetchFunc(...args);
|
|
223
|
-
if (!getIsMounted())
|
|
224
|
-
return;
|
|
225
|
-
setResult({ data: newData, error: undefined, isLoading: false });
|
|
226
|
-
}
|
|
227
|
-
catch (error) {
|
|
228
|
-
if (!getIsMounted())
|
|
229
|
-
return;
|
|
230
|
-
setResult({ data: undefined, error, isLoading: false });
|
|
231
|
-
}
|
|
232
|
-
}, [fetchFunc, ...args, ...deps]);
|
|
233
|
-
return { data, error, isLoading };
|
|
234
|
-
};
|
|
235
|
-
exports.useFetch = useFetch;
|
|
236
|
-
const __prglReactInstalled = () => Boolean(reactImports_1.React && reactImports_1.useRef);
|
|
237
|
-
exports.__prglReactInstalled = __prglReactInstalled;
|