@arrai-innovations/reactive-helpers 8.4.0 → 8.5.1
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/package.json +1 -1
- package/use/cancellableIntent.js +3 -1
- package/use/object.js +6 -0
- package/use/objectInstance.js +6 -0
package/package.json
CHANGED
package/use/cancellableIntent.js
CHANGED
|
@@ -87,6 +87,7 @@ export function useCancellableIntent({
|
|
|
87
87
|
|
|
88
88
|
const intentWatch = async () => {
|
|
89
89
|
let newWatchValues = deepUnref(Object.values(watchArguments));
|
|
90
|
+
const guardValues = deepUnref(Object.values(guardArguments));
|
|
90
91
|
if (isEqual(newWatchValues, previousWatchValues)) {
|
|
91
92
|
return;
|
|
92
93
|
}
|
|
@@ -94,7 +95,7 @@ export function useCancellableIntent({
|
|
|
94
95
|
await cancel();
|
|
95
96
|
if (Object.values(previousWatchValues).every(identity)) {
|
|
96
97
|
// if any guards are true, delay the watch.
|
|
97
|
-
if (
|
|
98
|
+
if (guardValues && !isEmpty(guardValues) && guardValues.some(identity)) {
|
|
98
99
|
delayedWatch = doIntentWatch;
|
|
99
100
|
return;
|
|
100
101
|
}
|
|
@@ -144,6 +145,7 @@ export function useCancellableIntent({
|
|
|
144
145
|
return {
|
|
145
146
|
state,
|
|
146
147
|
watchArguments: readonly(watchArguments),
|
|
148
|
+
guardArguments: readonly(guardArguments),
|
|
147
149
|
stop,
|
|
148
150
|
cancel,
|
|
149
151
|
};
|
package/use/object.js
CHANGED
|
@@ -40,6 +40,11 @@ export const useObject = ({ props, functions }) => {
|
|
|
40
40
|
managed.objectSubscription.clearError();
|
|
41
41
|
managed.objectInstance.clearError();
|
|
42
42
|
};
|
|
43
|
+
const clear = () => {
|
|
44
|
+
managed.objectSubscription.clearError();
|
|
45
|
+
// objectInstance.clear also does objectInstance.clearError
|
|
46
|
+
managed.objectInstance.clear();
|
|
47
|
+
};
|
|
43
48
|
return reactive({
|
|
44
49
|
managed: shallowReadonly(managed),
|
|
45
50
|
state: managed.objectCalculated.state,
|
|
@@ -52,6 +57,7 @@ export const useObject = ({ props, functions }) => {
|
|
|
52
57
|
updateFromSubscription: managed.objectSubscription.updateFromSubscription,
|
|
53
58
|
deleteFromSubscription: managed.objectSubscription.deleteFromSubscription,
|
|
54
59
|
clearError,
|
|
60
|
+
clear,
|
|
55
61
|
effectScope: es,
|
|
56
62
|
});
|
|
57
63
|
};
|
package/use/objectInstance.js
CHANGED
|
@@ -222,6 +222,11 @@ export function useObjectInstance({ props, functions = {} }) {
|
|
|
222
222
|
state.error = null;
|
|
223
223
|
}
|
|
224
224
|
|
|
225
|
+
function clear() {
|
|
226
|
+
clearError();
|
|
227
|
+
assignReactiveObject(state.object, {});
|
|
228
|
+
}
|
|
229
|
+
|
|
225
230
|
return reactive({
|
|
226
231
|
state,
|
|
227
232
|
retrieve,
|
|
@@ -230,5 +235,6 @@ export function useObjectInstance({ props, functions = {} }) {
|
|
|
230
235
|
patch,
|
|
231
236
|
delete: deleteFn,
|
|
232
237
|
clearError,
|
|
238
|
+
clear,
|
|
233
239
|
});
|
|
234
240
|
}
|