@cripty2001/utils 0.0.164 → 0.0.166
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.js +8 -19
- package/package.json +1 -1
package/dist/react-whispr.js
CHANGED
|
@@ -37,11 +37,13 @@ const Searcher_1 = require("./Searcher");
|
|
|
37
37
|
function useWhisprValue(w, computer = (d) => d) {
|
|
38
38
|
const value_w = (0, react_1.useRef)(whispr_1.Whispr.from({ w }, ({ w }) => computer(w))).current;
|
|
39
39
|
const [value, setValue] = (0, react_1.useState)(value_w.value);
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
40
|
+
(0, react_1.useEffect)(() => {
|
|
41
|
+
return value_w.subscribe((newValue) => {
|
|
42
|
+
if ((0, lodash_1.isEqual)(newValue, value))
|
|
43
|
+
return;
|
|
44
|
+
setValue(newValue);
|
|
45
|
+
});
|
|
46
|
+
}, [value_w]);
|
|
45
47
|
return value;
|
|
46
48
|
}
|
|
47
49
|
/**
|
|
@@ -361,19 +363,6 @@ function useAsyncInput(value, setValue, handler) {
|
|
|
361
363
|
setMeta(value._meta);
|
|
362
364
|
}
|
|
363
365
|
}, [value, meta, setMeta]);
|
|
364
|
-
// // React has always random problems with stale closures, expecially in async environment.
|
|
365
|
-
// // On the other side, the watched param of useAsync is always perfect
|
|
366
|
-
// // We aren't taking any risks, here
|
|
367
|
-
// type AsyncPack = {
|
|
368
|
-
// c: C,
|
|
369
|
-
// ts: number,
|
|
370
|
-
// }
|
|
371
|
-
// const asyncPack: AsyncPack = useMemo(() => {
|
|
372
|
-
// return {
|
|
373
|
-
// c: meta.config,
|
|
374
|
-
// ts: meta.ts,
|
|
375
|
-
// }
|
|
376
|
-
// }, [meta]);
|
|
377
366
|
const result_d = useAsync(async ({ config, ts }) => {
|
|
378
367
|
const r = await handler(config);
|
|
379
368
|
return {
|
|
@@ -391,7 +380,7 @@ function useAsyncInput(value, setValue, handler) {
|
|
|
391
380
|
if (result._meta.ts <= value._meta.ts)
|
|
392
381
|
return;
|
|
393
382
|
setValue(result);
|
|
394
|
-
}, [result, setValue]);
|
|
383
|
+
}, [result, value, setValue]);
|
|
395
384
|
const returnedSetValue = (0, react_1.useCallback)((updater) => {
|
|
396
385
|
const cloned = structuredClone(meta.config);
|
|
397
386
|
const new_data = updater(cloned);
|
package/package.json
CHANGED