@arrai-innovations/reactive-helpers 7.0.0 → 7.1.0
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/.vscode/extensions.json +1 -1
- package/package.json +1 -1
- package/use/list.js +35 -17
- package/use/object.js +37 -19
package/.vscode/extensions.json
CHANGED
package/package.json
CHANGED
package/use/list.js
CHANGED
|
@@ -3,7 +3,7 @@ import { useListInstance } from "./listInstance";
|
|
|
3
3
|
import { useListRelated } from "./listRelated";
|
|
4
4
|
import { useListSubscription } from "./listSubscription";
|
|
5
5
|
import { usePagedListInstance } from "./paginatedListInstance";
|
|
6
|
-
import { reactive, shallowReactive, shallowReadonly, toRef } from "vue";
|
|
6
|
+
import { effectScope, reactive, shallowReactive, shallowReadonly, toRef } from "vue";
|
|
7
7
|
|
|
8
8
|
export const useLists = (listArgs) => {
|
|
9
9
|
const lists = {};
|
|
@@ -22,30 +22,48 @@ export const useList = ({ props, functions, paged = false, keepOldPages = false
|
|
|
22
22
|
listCalculated: null,
|
|
23
23
|
});
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
props,
|
|
27
|
-
functions,
|
|
28
|
-
keepOldPages,
|
|
29
|
-
});
|
|
25
|
+
const es = effectScope();
|
|
30
26
|
|
|
31
|
-
|
|
32
|
-
listInstance:
|
|
33
|
-
|
|
34
|
-
|
|
27
|
+
es.run(() => {
|
|
28
|
+
managed.listInstance = (paged ? usePagedListInstance : useListInstance)({
|
|
29
|
+
props,
|
|
30
|
+
functions,
|
|
31
|
+
keepOldPages,
|
|
32
|
+
});
|
|
35
33
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
34
|
+
managed.listSubscription = useListSubscription({
|
|
35
|
+
listInstance: managed.listInstance,
|
|
36
|
+
});
|
|
37
|
+
managed.listSubscription.state.intendToList = toRef(props, "intendToList");
|
|
40
38
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
39
|
+
managed.listRelated = useListRelated({
|
|
40
|
+
parentState: managed.listSubscription.state,
|
|
41
|
+
relatedObjectsRules: toRef(props, "relatedObjectsRules"),
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
managed.listCalculated = useListCalculated({
|
|
45
|
+
parentState: managed.listRelated.state,
|
|
46
|
+
calculatedObjectsRules: toRef(props, "calculatedObjectsRules"),
|
|
47
|
+
});
|
|
44
48
|
});
|
|
45
49
|
|
|
50
|
+
const clearError = (error) => {
|
|
51
|
+
managed.listSubscription.clearError(error);
|
|
52
|
+
managed.listInstance.clearError(error);
|
|
53
|
+
};
|
|
54
|
+
|
|
46
55
|
return reactive({
|
|
47
56
|
// we manage the keys on both of these, so hands off the root.
|
|
48
57
|
managed: shallowReadonly(managed),
|
|
49
58
|
state: managed.listCalculated.state,
|
|
59
|
+
list: managed.listInstance.list,
|
|
60
|
+
addListObject: managed.listInstance.addListObject,
|
|
61
|
+
updateListObject: managed.listInstance.updateListObject,
|
|
62
|
+
deleteListObject: managed.listInstance.deleteListObject,
|
|
63
|
+
clearList: managed.listInstance.clearList,
|
|
64
|
+
clearError,
|
|
65
|
+
getFakeId: managed.listInstance.getFakeId,
|
|
66
|
+
defaultPageCallback: managed.listInstance.defaultPageCallback,
|
|
67
|
+
effectScope: es,
|
|
50
68
|
});
|
|
51
69
|
};
|
package/use/object.js
CHANGED
|
@@ -2,7 +2,7 @@ import { useObjectCalculated } from "./objectCalculated";
|
|
|
2
2
|
import { useObjectInstance } from "./objectInstance";
|
|
3
3
|
import { useObjectRelated } from "./objectRelated";
|
|
4
4
|
import { useObjectSubscription } from "./objectSubscription";
|
|
5
|
-
import { reactive, shallowReadonly, toRef } from "vue";
|
|
5
|
+
import { effectScope, reactive, shallowReadonly, toRef } from "vue";
|
|
6
6
|
|
|
7
7
|
// Manages a chain of useObject* functions
|
|
8
8
|
export const useObject = ({ props, functions }) => {
|
|
@@ -13,27 +13,45 @@ export const useObject = ({ props, functions }) => {
|
|
|
13
13
|
objectCalculated: null,
|
|
14
14
|
});
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
16
|
+
const es = effectScope();
|
|
17
|
+
|
|
18
|
+
es.run(() => {
|
|
19
|
+
managed.objectInstance = useObjectInstance({
|
|
20
|
+
props,
|
|
21
|
+
functions,
|
|
22
|
+
});
|
|
23
|
+
managed.objectSubscription = useObjectSubscription({
|
|
24
|
+
objectInstance: managed.objectInstance,
|
|
25
|
+
props: reactive({
|
|
26
|
+
intendToSubscribe: toRef(props, "intendToSubscribe"),
|
|
27
|
+
intendToRetrieve: toRef(props, "intendToRetrieve"),
|
|
28
|
+
}),
|
|
29
|
+
});
|
|
30
|
+
managed.objectRelated = useObjectRelated({
|
|
31
|
+
parentState: managed.objectSubscription.state,
|
|
32
|
+
relatedObjectRules: toRef(props, "relatedObjectRules"),
|
|
33
|
+
});
|
|
34
|
+
managed.objectCalculated = useObjectCalculated({
|
|
35
|
+
parentState: managed.objectRelated.state,
|
|
36
|
+
calculatedObjectRules: toRef(props, "calculatedObjectRules"),
|
|
37
|
+
});
|
|
34
38
|
});
|
|
39
|
+
const clearError = () => {
|
|
40
|
+
managed.objectSubscription.clearError();
|
|
41
|
+
managed.objectInstance.clearError();
|
|
42
|
+
};
|
|
35
43
|
return reactive({
|
|
36
44
|
managed: shallowReadonly(managed),
|
|
37
45
|
state: managed.objectCalculated.state,
|
|
46
|
+
retrieve: managed.objectInstance.retrieve,
|
|
47
|
+
create: managed.objectInstance.create,
|
|
48
|
+
update: managed.objectInstance.update,
|
|
49
|
+
patch: managed.objectInstance.patch,
|
|
50
|
+
subscribe: managed.objectSubscription.subscribe,
|
|
51
|
+
unsubscribe: managed.objectSubscription.unsubscribe,
|
|
52
|
+
updateFromSubscription: managed.objectSubscription.updateFromSubscription,
|
|
53
|
+
deleteFromSubscription: managed.objectSubscription.deleteFromSubscription,
|
|
54
|
+
clearError,
|
|
55
|
+
effectScope: es,
|
|
38
56
|
});
|
|
39
57
|
};
|