@arrai-innovations/reactive-helpers 6.1.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 +4 -4
- package/use/list.js +35 -17
- package/use/object.js +37 -19
package/.vscode/extensions.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arrai-innovations/reactive-helpers",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.1.0",
|
|
4
4
|
"description": "VueJS 3 utility composition functions to help manipulate objects and lists.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"directories": {
|
|
@@ -30,9 +30,9 @@
|
|
|
30
30
|
"@commitlint/cli": "^16.2.4",
|
|
31
31
|
"@trivago/prettier-plugin-sort-imports": "^4.1.1",
|
|
32
32
|
"@types/jest": "^27.5.0",
|
|
33
|
-
"@vue/compiler-sfc": "^3.
|
|
33
|
+
"@vue/compiler-sfc": "^3.3.4",
|
|
34
34
|
"@vue/eslint-config-prettier": "^7.0.0",
|
|
35
|
-
"@vue/test-utils": "^2.
|
|
35
|
+
"@vue/test-utils": "^2.3.2",
|
|
36
36
|
"@vue/vue3-jest": "^27.0.0",
|
|
37
37
|
"babel-eslint": "^10.1.0",
|
|
38
38
|
"babel-jest": "^27.5.1",
|
|
@@ -54,6 +54,6 @@
|
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
56
|
"lodash-es": "^4.17.21",
|
|
57
|
-
"vue": "^3.
|
|
57
|
+
"vue": "^3.3.4"
|
|
58
58
|
}
|
|
59
59
|
}
|
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
|
};
|