@cripty2001/utils 0.0.82 → 0.0.84
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/Appserver/client.js +2 -0
- package/dist/react-whispr.js +23 -13
- package/package.json +1 -1
package/dist/Appserver/client.js
CHANGED
package/dist/react-whispr.js
CHANGED
|
@@ -108,19 +108,29 @@ function useSynced(def, value, setValue) {
|
|
|
108
108
|
(0, react_1.useEffect)(() => {
|
|
109
109
|
setValueRef.current = setValue;
|
|
110
110
|
}, [setValue]);
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
(
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
111
|
+
// Only sync downstream (external -> local)
|
|
112
|
+
(0, react_1.useEffect)(() => {
|
|
113
|
+
if (value === undefined)
|
|
114
|
+
return;
|
|
115
|
+
if ((0, lodash_1.isEqual)(v, value))
|
|
116
|
+
return;
|
|
117
|
+
console.log('SYNC DOWNSTREAM', value);
|
|
118
|
+
setV(value);
|
|
119
|
+
}, [value]);
|
|
120
|
+
// Return a setter that updates both
|
|
121
|
+
const syncedSetter = (0, react_1.useCallback)((newValue) => {
|
|
122
|
+
setV(prev => {
|
|
123
|
+
const resolved = typeof newValue === 'function'
|
|
124
|
+
? newValue(prev)
|
|
125
|
+
: newValue;
|
|
126
|
+
// Update external immediately if available
|
|
127
|
+
if (setValueRef.current) {
|
|
128
|
+
setValueRef.current(resolved);
|
|
129
|
+
}
|
|
130
|
+
return resolved;
|
|
131
|
+
});
|
|
132
|
+
}, []);
|
|
133
|
+
return [v, syncedSetter];
|
|
124
134
|
}
|
|
125
135
|
/**
|
|
126
136
|
*
|
package/package.json
CHANGED