@cripty2001/utils 0.0.186 → 0.0.187
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 +1 -1
- package/dist/react-whispr.js +3 -3
- package/package.json +1 -1
package/dist/react-whispr.d.ts
CHANGED
|
@@ -31,7 +31,7 @@ export declare function useWhispr<T>(data: T | Whispr<T>): Whispr<T>;
|
|
|
31
31
|
* @param cb The callback to call on value change
|
|
32
32
|
* @param unsafe If true, the callback will be allowed to throw errors, that will then bubble up
|
|
33
33
|
*/
|
|
34
|
-
export declare function useOnWhispr<T>(w: Whispr<T>,
|
|
34
|
+
export declare function useOnWhispr<T>(w: Whispr<T>, cb: (value: T) => void, unsafe?: boolean): void;
|
|
35
35
|
/**
|
|
36
36
|
* Return a reactive current timestamp (ms)
|
|
37
37
|
* @returns The current timestamp
|
package/dist/react-whispr.js
CHANGED
|
@@ -75,7 +75,7 @@ function useWhispr(data) {
|
|
|
75
75
|
* @param cb The callback to call on value change
|
|
76
76
|
* @param unsafe If true, the callback will be allowed to throw errors, that will then bubble up
|
|
77
77
|
*/
|
|
78
|
-
function useOnWhispr(w, unsafe = false
|
|
78
|
+
function useOnWhispr(w, cb, unsafe = false) {
|
|
79
79
|
(0, react_1.useEffect)(() => {
|
|
80
80
|
const unsub = w.subscribe(cb, undefined, unsafe);
|
|
81
81
|
return () => unsub();
|
|
@@ -213,11 +213,11 @@ function useAsync(f, data, debouce = 200) {
|
|
|
213
213
|
*/
|
|
214
214
|
function useAsyncEffect(f, data, debounce = 200) {
|
|
215
215
|
const dispatcher = useAsync(f, data, debounce);
|
|
216
|
-
useOnWhispr(dispatcher.data,
|
|
216
|
+
useOnWhispr(dispatcher.data, (data) => {
|
|
217
217
|
if (!data.loading && !data.ok) {
|
|
218
218
|
throw data.error;
|
|
219
219
|
}
|
|
220
|
-
});
|
|
220
|
+
}, true);
|
|
221
221
|
}
|
|
222
222
|
/**
|
|
223
223
|
* Format a timestamp into a relative time string (e.g. "5 minutes ago", "in 2 hours"), using the browser locale.
|
package/package.json
CHANGED