@cripty2001/utils 0.0.165 → 0.0.167
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 {
|
|
@@ -400,7 +389,7 @@ function useAsyncInput(value, setValue, handler) {
|
|
|
400
389
|
config: chosen,
|
|
401
390
|
ts: Date.now(),
|
|
402
391
|
});
|
|
403
|
-
}, [setMeta]);
|
|
392
|
+
}, [meta, setMeta]);
|
|
404
393
|
return [
|
|
405
394
|
meta.config,
|
|
406
395
|
returnedSetValue,
|
package/package.json
CHANGED