@arrai-innovations/reactive-helpers 7.0.0 → 7.1.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.
@@ -1,3 +1,3 @@
1
1
  {
2
- "recommendations": ["Vue.volar", "dbaeumer.vscode-eslint"]
2
+ "recommendations": ["dbaeumer.vscode-eslint", "znck.vue"]
3
3
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arrai-innovations/reactive-helpers",
3
- "version": "7.0.0",
3
+ "version": "7.1.1",
4
4
  "description": "VueJS 3 utility composition functions to help manipulate objects and lists.",
5
5
  "main": "index.js",
6
6
  "directories": {
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
- managed.listInstance = (paged ? usePagedListInstance : useListInstance)({
26
- props,
27
- functions,
28
- keepOldPages,
29
- });
25
+ const es = effectScope();
30
26
 
31
- managed.listSubscription = useListSubscription({
32
- listInstance: managed.listInstance,
33
- });
34
- managed.listSubscription.state.intendToList = toRef(props, "intendToList");
27
+ es.run(() => {
28
+ managed.listInstance = (paged ? usePagedListInstance : useListInstance)({
29
+ props,
30
+ functions,
31
+ keepOldPages,
32
+ });
35
33
 
36
- managed.listRelated = useListRelated({
37
- parentState: managed.listSubscription.state,
38
- relatedObjectsRules: toRef(props, "relatedObjectsRules"),
39
- });
34
+ managed.listSubscription = useListSubscription({
35
+ listInstance: managed.listInstance,
36
+ });
37
+ managed.listSubscription.state.intendToList = toRef(props, "intendToList");
40
38
 
41
- managed.listCalculated = useListCalculated({
42
- parentState: managed.listRelated.state,
43
- calculatedObjectsRules: toRef(props, "calculatedObjectsRules"),
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
- managed.objectInstance = useObjectInstance({
17
- props,
18
- functions,
19
- });
20
- managed.objectSubscription = useObjectSubscription({
21
- objectInstance: managed.objectInstance,
22
- props: reactive({
23
- intendToSubscribe: toRef(props, "intendToSubscribe"),
24
- intendToRetrieve: toRef(props, "intendToRetrieve"),
25
- }),
26
- });
27
- managed.objectRelated = useObjectRelated({
28
- parentState: managed.objectSubscription.state,
29
- relatedObjectRules: toRef(props, "relatedObjectRules"),
30
- });
31
- managed.objectCalculated = useObjectCalculated({
32
- parentState: managed.objectRelated.state,
33
- calculatedObjectRules: toRef(props, "calculatedObjectRules"),
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
  };
@@ -42,6 +42,7 @@ export function useLifecycleDebug(categories, includes = [], excludes = []) {
42
42
  continue;
43
43
  }
44
44
  const myCategories = new Set(categories);
45
+ myCategories.add("lifecycle");
45
46
  myCategories.add(key);
46
47
  const eventString = `${key} called`;
47
48
  const debugMessage = useDebugMessage(myCategories);