@arrai-innovations/reactive-helpers 2.5.0 → 2.5.2
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/listCalculated.js +6 -0
- package/use/listRelated.js +6 -0
- package/use/objectCalculated.js +5 -1
- package/utils/keyDiff.js +12 -5
package/package.json
CHANGED
package/use/listCalculated.js
CHANGED
|
@@ -101,6 +101,12 @@ export function useListCalculated({
|
|
|
101
101
|
const es = effectScope();
|
|
102
102
|
|
|
103
103
|
es.run(() => {
|
|
104
|
+
state.loading = toRef(parentState, "loading");
|
|
105
|
+
state.errored = toRef(parentState, "errored");
|
|
106
|
+
state.error = toRef(parentState, "error");
|
|
107
|
+
|
|
108
|
+
state.retrieveArgs = toRef(parentState, "retrieveArgs");
|
|
109
|
+
state.listArgs = toRef(parentState, "listArgs");
|
|
104
110
|
state.order = toRef(parentState, "order");
|
|
105
111
|
state.objectsInOrder = computed(() => state.order.map((id) => state.objects[id]));
|
|
106
112
|
|
package/use/listRelated.js
CHANGED
|
@@ -131,6 +131,12 @@ export function useListRelated({
|
|
|
131
131
|
const es = effectScope();
|
|
132
132
|
|
|
133
133
|
es.run(() => {
|
|
134
|
+
state.loading = toRef(parentState, "loading");
|
|
135
|
+
state.errored = toRef(parentState, "errored");
|
|
136
|
+
state.error = toRef(parentState, "error");
|
|
137
|
+
|
|
138
|
+
state.retrieveArgs = toRef(parentState, "retrieveArgs");
|
|
139
|
+
state.listArgs = toRef(parentState, "listArgs");
|
|
134
140
|
state.order = toRef(parentState, "order");
|
|
135
141
|
state.objectsInOrder = computed(() => state.order.map((id) => state.objects[id]));
|
|
136
142
|
|
package/use/objectCalculated.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { computed, effectScope, onScopeDispose, reactive, watch } from "vue";
|
|
1
|
+
import { computed, effectScope, onScopeDispose, reactive, toRef, watch } from "vue";
|
|
2
2
|
import { keyDiff } from "../utils";
|
|
3
3
|
|
|
4
4
|
export function useObjectCalculateds(instances, args) {
|
|
@@ -61,6 +61,10 @@ export function useObjectCalculated({
|
|
|
61
61
|
return false;
|
|
62
62
|
},
|
|
63
63
|
});
|
|
64
|
+
state.loading = toRef(parentState, "loading");
|
|
65
|
+
state.error = toRef(parentState, "error");
|
|
66
|
+
state.errored = toRef(parentState, "errored");
|
|
67
|
+
state.deleted = toRef(parentState, "deleted");
|
|
64
68
|
|
|
65
69
|
watch(
|
|
66
70
|
[() => Object.keys(state.calculatedObjectRules)],
|
package/utils/keyDiff.js
CHANGED
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
import { difference, intersection } from "./set.js";
|
|
2
2
|
|
|
3
|
-
export function keyDiff(newKeys, oldKeys) {
|
|
3
|
+
export function keyDiff(newKeys, oldKeys, { sameKeys = true, removedKeys = true, addedKeys = true } = {}) {
|
|
4
4
|
const newKeysSet = new Set(newKeys);
|
|
5
5
|
const oldKeysSet = new Set(oldKeys);
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
const returnValue = {};
|
|
7
|
+
if (sameKeys) {
|
|
8
|
+
returnValue.sameKeys = intersection(newKeysSet, oldKeysSet);
|
|
9
|
+
}
|
|
10
|
+
if (removedKeys) {
|
|
11
|
+
returnValue.removedKeys = difference(oldKeysSet, newKeysSet);
|
|
12
|
+
}
|
|
13
|
+
if (addedKeys) {
|
|
14
|
+
returnValue.addedKeys = difference(newKeysSet, oldKeysSet);
|
|
15
|
+
}
|
|
16
|
+
return returnValue;
|
|
10
17
|
}
|