@cripty2001/utils 0.0.249 → 0.0.250
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/react-whispr.d.ts +2 -2
- package/dist/react-whispr.js +11 -4
- package/package.json +1 -1
package/dist/react-whispr.d.ts
CHANGED
|
@@ -95,9 +95,9 @@ export declare function useAsync<I, O>(f: (input: I, setProgress: (p: number) =>
|
|
|
95
95
|
* @param interval The interval to re-execute the async function. If null, the async function will not be re-executed.
|
|
96
96
|
* @param f @see useAsync
|
|
97
97
|
*
|
|
98
|
-
* @returns @see useAsync
|
|
98
|
+
* @returns [@see useAsync, A function to trigger a manual refresh]
|
|
99
99
|
*/
|
|
100
|
-
export declare function useAsyncPeriodic<I, O>(data: I, interval: number, f: (input: I, setProgress: (p: number) => void, signal: AbortSignal) => Promise<O>): Dispatcher<any, O
|
|
100
|
+
export declare function useAsyncPeriodic<I, O>(data: I, interval: number, f: (input: I, setProgress: (p: number) => void, signal: AbortSignal) => Promise<O>): [Dispatcher<any, O>, () => void];
|
|
101
101
|
/**
|
|
102
102
|
* Async version of useEffect with debouncing. Executes an async function as a side effect when data changes.
|
|
103
103
|
*
|
package/dist/react-whispr.js
CHANGED
|
@@ -204,17 +204,24 @@ function useAsync(f, data, debouce = 200) {
|
|
|
204
204
|
* @param interval The interval to re-execute the async function. If null, the async function will not be re-executed.
|
|
205
205
|
* @param f @see useAsync
|
|
206
206
|
*
|
|
207
|
-
* @returns @see useAsync
|
|
207
|
+
* @returns [@see useAsync, A function to trigger a manual refresh]
|
|
208
208
|
*/
|
|
209
209
|
function useAsyncPeriodic(data, interval, f) {
|
|
210
210
|
const timer = useClock(interval);
|
|
211
|
+
const [refresh, setRefresh] = (0, react_1.useState)(Math.random());
|
|
211
212
|
const bundle = (0, react_1.useMemo)(() => {
|
|
212
213
|
return {
|
|
213
214
|
data,
|
|
214
|
-
timer
|
|
215
|
+
timer,
|
|
216
|
+
refresh
|
|
215
217
|
};
|
|
216
|
-
}, [data, timer]);
|
|
217
|
-
return
|
|
218
|
+
}, [data, timer, refresh]);
|
|
219
|
+
return [
|
|
220
|
+
useAsync((i, p, s) => f(i.data, p, s), bundle),
|
|
221
|
+
() => {
|
|
222
|
+
setRefresh(Math.random());
|
|
223
|
+
}
|
|
224
|
+
];
|
|
218
225
|
}
|
|
219
226
|
/**
|
|
220
227
|
* Async version of useEffect with debouncing. Executes an async function as a side effect when data changes.
|
package/package.json
CHANGED