@arrai-innovations/reactive-helpers 5.0.1 → 6.0.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arrai-innovations/reactive-helpers",
3
- "version": "5.0.1",
3
+ "version": "6.0.0",
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,116 +3,49 @@ import { useListInstance } from "./listInstance";
3
3
  import { useListRelated } from "./listRelated";
4
4
  import { useListSubscription } from "./listSubscription";
5
5
  import { usePagedListInstance } from "./paginatedListInstance";
6
- import { effectScope, reactive, shallowReactive, shallowReadonly, toRef, watch } from "vue";
6
+ import { reactive, shallowReactive, shallowReadonly, toRef } from "vue";
7
+
8
+ export const useLists = (listArgs) => {
9
+ const lists = {};
10
+ for (const [key, value] of Object.entries(listArgs)) {
11
+ lists[key] = useList(value);
12
+ }
13
+ return lists;
14
+ };
7
15
 
8
16
  // the big brother of useObject, managing a chain of useList* instances.
9
- export const useList = ({ props, functions, paged = false, keepOldPages = false, passThroughPropertyNames = [] }) => {
17
+ export const useList = ({ props, functions, paged = false, keepOldPages = false }) => {
10
18
  const managed = shallowReactive({
11
19
  listInstance: null,
12
20
  listSubscription: null,
13
21
  listRelated: null,
14
22
  listCalculated: null,
15
23
  });
16
- const es = effectScope();
17
24
 
18
25
  managed.listInstance = (paged ? usePagedListInstance : useListInstance)({
19
- crudArgs: toRef(props, "crudArgs"),
26
+ props,
20
27
  functions,
21
- retrieveArgs: toRef(props, "retrieveArgs"),
22
- listArgs: toRef(props, "listArgs"),
23
28
  keepOldPages,
24
29
  });
25
30
 
26
- const intentPropsWatch = () => {
27
- es.run(() => {
28
- let nextState = managed.listInstance?.state;
29
- // true or false, having a key is intent to use
30
- const hasIntendToList = "intendToList" in props;
31
- if (hasIntendToList && !managed.listSubscription) {
32
- managed.listSubscription = useListSubscription({
33
- listInstance: managed.listInstance,
34
- });
35
- managed.listSubscription.state.intendToList = toRef(props, "intendToList");
36
- } else if (!hasIntendToList && managed.listSubscription) {
37
- managed.listSubscription.effectScope.stop();
38
- managed.listSubscription = null;
39
- }
40
- const hasRelatedObjectRules = "relatedObjectsRules" in props;
41
- if (hasRelatedObjectRules && !managed.listRelated) {
42
- nextState = managed.listSubscription?.state || nextState;
43
- managed.listRelated = useListRelated({
44
- parentState: nextState,
45
- relatedObjectsRules: toRef(props, "relatedObjectsRules"),
46
- });
47
- } else if (!hasRelatedObjectRules && managed.listRelated) {
48
- managed.listRelated.effectScope.stop();
49
- managed.listRelated = null;
50
- }
51
- const hasCalculatedObjectRules = "calculatedObjectsRules" in props;
52
- if (hasCalculatedObjectRules && !managed.listCalculated) {
53
- nextState = managed.listRelated?.state || nextState;
54
- managed.listCalculated = useListCalculated({
55
- parentState: nextState,
56
- calculatedObjectsRules: toRef(props, "calculatedObjectsRules"),
57
- });
58
- } else if (!hasCalculatedObjectRules && managed.listCalculated) {
59
- managed.listCalculated.effectScope.stop();
60
- managed.listCalculated = null;
61
- }
62
- });
63
- };
31
+ managed.listSubscription = useListSubscription({
32
+ listInstance: managed.listInstance,
33
+ });
34
+ managed.listSubscription.state.intendToList = toRef(props, "intendToList");
64
35
 
65
- const exposedState = reactive({});
36
+ managed.listRelated = useListRelated({
37
+ parentState: managed.listSubscription.state,
38
+ relatedObjectsRules: toRef(props, "relatedObjectsRules"),
39
+ });
66
40
 
67
- es.run(() => {
68
- watch(
69
- [
70
- //
71
- toRef(props, "intendToList"),
72
- toRef(props, "relatedObjectsRules"),
73
- toRef(props, "calculatedObjectsRules"),
74
- ],
75
- intentPropsWatch,
76
- { immediate: true }
77
- );
78
- const propertiesToRelay = [
79
- "loading",
80
- "error",
81
- "errored",
82
- "objects",
83
- "order",
84
- "objectsInOrder",
85
- "running",
86
- "relatedObjects",
87
- "calculatedObjects",
88
- "totalRecords",
89
- "totalPages",
90
- "perPage",
91
- ...passThroughPropertyNames,
92
- ];
93
- watch(
94
- () =>
95
- managed.listCalculated?.state ||
96
- managed.listRelated?.state ||
97
- managed.listSubscription?.state ||
98
- managed.listInstance?.state,
99
- (newState, oldState) => {
100
- if (newState !== oldState && newState) {
101
- propertiesToRelay.forEach((x) => {
102
- exposedState[x] = toRef(newState, x);
103
- });
104
- }
105
- },
106
- {
107
- immediate: true,
108
- }
109
- );
41
+ managed.listCalculated = useListCalculated({
42
+ parentState: managed.listRelated.state,
43
+ calculatedObjectsRules: toRef(props, "calculatedObjectsRules"),
110
44
  });
111
45
 
112
- return {
46
+ return reactive({
113
47
  // we manage the keys on both of these, so hands off the root.
114
48
  managed: shallowReadonly(managed),
115
- state: shallowReadonly(exposedState),
116
- effectScope: es,
117
- };
49
+ state: managed.listCalculated.state,
50
+ });
118
51
  };
@@ -1,8 +1,18 @@
1
1
  import { keyDiff, loadingCombine } from "../utils";
2
+ import { listInstanceStateKeys } from "./listInstance";
3
+ import { listRelatedStateKeys } from "./listRelated";
4
+ import { listSubscriptionStateKeys } from "./listSubscription";
2
5
  import { useWatchesRunning } from "./watchesRunning";
3
6
  import isEmpty from "lodash-es/isEmpty";
4
7
  import { computed, effectScope, onScopeDispose, reactive, toRef, watch } from "vue";
5
8
 
9
+ export const listCalculatedStateKeys = [
10
+ "calculatedObjects",
11
+ "calculatedObjectsParentStateObjectsWatchRunning",
12
+ "calculatedObjectsRules",
13
+ "calculatedObjectsWatchRunning",
14
+ ];
15
+
6
16
  export function useListCalculateds(instances, args) {
7
17
  for (const [key, value] of Object.entries(args)) {
8
18
  useListCalculated({
@@ -15,52 +25,44 @@ export function useListCalculateds(instances, args) {
15
25
  // the simpler sibling of useListRelated
16
26
  // rules are just keys to functions that will be called with the object
17
27
  // and the result will be added as a computed property
18
- export function useListCalculated({
19
- parentState,
20
- calculatedObjectsRules,
21
- calculatedObjectsPropertyName = "calculatedObjects", // NOT REACTIVE
22
- passThroughPropertyNames = ["relatedObjects", "totalRecords", "totalPages", "perPage"], // NOT REACTIVE
23
- }) {
28
+ export function useListCalculated({ parentState, calculatedObjectsRules }) {
24
29
  const state = reactive({
25
30
  calculatedObjectsRules,
26
- calculatedObjectsObjects: {},
27
- parentStateObjectsWatchRunning: false,
31
+ calculatedObjects: {},
32
+ calculatedObjectsParentStateObjectsWatchRunning: false,
28
33
  calculatedObjectsWatchRunning: false,
29
34
  });
30
35
  const calculatedObjectsEffectScopes = {};
31
36
 
32
- // don't change calculatedObjectsPropertyName on us or it will break
33
- const copn = calculatedObjectsPropertyName + "";
34
-
35
37
  function parentStateObjectsWatch() {
36
38
  const { addedKeys, removedKeys } = keyDiff(
37
39
  Object.keys(parentState.objects),
38
- Object.keys(state.calculatedObjectsObjects)
40
+ Object.keys(state.calculatedObjects)
39
41
  );
40
42
  for (const removedKey of removedKeys) {
41
- delete state.calculatedObjectsObjects[removedKey];
43
+ delete state.calculatedObjects[removedKey];
42
44
  if (calculatedObjectsEffectScopes[removedKey]) {
43
45
  calculatedObjectsEffectScopes[removedKey].stop();
44
46
  delete calculatedObjectsEffectScopes[removedKey];
45
47
  }
46
48
  }
47
49
  for (const addedKey of addedKeys) {
48
- state.calculatedObjectsObjects[addedKey] = {};
50
+ state.calculatedObjects[addedKey] = {};
49
51
  }
50
- state.parentStateObjectsWatchRunning = false;
52
+ state.calculatedObjectsParentStateObjectsWatchRunning = false;
51
53
  }
52
54
 
53
55
  function calculatedObjectsWatch() {
54
56
  const calculatedObjectsRulesIsEmpty = !state.calculatedObjectsRules || isEmpty(state.calculatedObjectsRules);
55
- for (const objectKey of Object.keys(state.calculatedObjectsObjects)) {
57
+ for (const objectKey of Object.keys(state.calculatedObjects)) {
56
58
  if (!calculatedObjectsEffectScopes[objectKey]) {
57
59
  calculatedObjectsEffectScopes[objectKey] = effectScope();
58
60
  }
59
61
  const originalObject = parentState.objects[objectKey];
60
- if (!state.calculatedObjectsObjects[objectKey]) {
61
- state.calculatedObjectsObjects[objectKey] = {};
62
+ if (!state.calculatedObjects[objectKey]) {
63
+ state.calculatedObjects[objectKey] = {};
62
64
  }
63
- const calculatedObjectsObject = state.calculatedObjectsObjects[objectKey];
65
+ const calculatedObjectsObject = state.calculatedObjects[objectKey];
64
66
  let removedRuleKeys, addedRuleKeys;
65
67
  if (!calculatedObjectsRulesIsEmpty) {
66
68
  ({ removedKeys: removedRuleKeys, addedKeys: addedRuleKeys } = keyDiff(
@@ -93,24 +95,20 @@ export function useListCalculated({
93
95
  const es = effectScope();
94
96
 
95
97
  es.run(() => {
96
- state.loading = toRef(parentState, "loading");
97
- state.errored = toRef(parentState, "errored");
98
- state.error = toRef(parentState, "error");
99
-
100
- state.retrieveArgs = toRef(parentState, "retrieveArgs");
101
- state.listArgs = toRef(parentState, "listArgs");
102
- state.order = toRef(parentState, "order");
103
- state.objects = toRef(parentState, "objects");
104
- state.objectsInOrder = toRef(parentState, "objectsInOrder");
105
- state[copn] = toRef(state, "calculatedObjectsObjects");
106
- for (let key of passThroughPropertyNames) {
98
+ for (const key of listInstanceStateKeys) {
99
+ state[key] = toRef(parentState, key);
100
+ }
101
+ for (const key of listSubscriptionStateKeys) {
102
+ state[key] = toRef(parentState, key);
103
+ }
104
+ for (const key of listRelatedStateKeys) {
107
105
  state[key] = toRef(parentState, key);
108
106
  }
109
107
 
110
108
  watch(() => Object.keys(parentState.objects), parentStateObjectsWatch, { immediate: true });
111
109
  watch(
112
110
  [
113
- () => Object.keys(state.calculatedObjectsObjects),
111
+ () => Object.keys(state.calculatedObjects),
114
112
  () =>
115
113
  state.calculatedObjectsRules
116
114
  ? Object.keys(state.calculatedObjectsRules)
@@ -127,7 +125,7 @@ export function useListCalculated({
127
125
  ),
128
126
  ],
129
127
  watchSentinelRefs: [
130
- toRef(state, "parentStateObjectsWatchRunning"),
128
+ toRef(state, "calculatedObjectsParentStateObjectsWatchRunning"),
131
129
  toRef(state, "calculatedObjectsWatchRunning"),
132
130
  ],
133
131
  });
@@ -3,7 +3,7 @@ import { getFakeId } from "../utils/getFakeId";
3
3
  import inspect from "browser-util-inspect";
4
4
  import cloneDeep from "lodash-es/cloneDeep";
5
5
  import isFunction from "lodash-es/isFunction";
6
- import { computed, effectScope, reactive } from "vue";
6
+ import { computed, effectScope, reactive, toRef, watchEffect } from "vue";
7
7
 
8
8
  export class ListError extends Error {
9
9
  constructor(message, code) {
@@ -18,6 +18,22 @@ const defaultCrud = {
18
18
  list: undefined,
19
19
  };
20
20
 
21
+ export const listInstanceStateKeys = [
22
+ "crud",
23
+ "retrieveArgs",
24
+ "listArgs",
25
+ "objects",
26
+ "loading",
27
+ "errored",
28
+ "error",
29
+ "objectsInOrder",
30
+ "order",
31
+ // when paged
32
+ "totalRecords",
33
+ "totalPages",
34
+ "perPage",
35
+ ];
36
+
21
37
  export function setListInstanceCrud({ list, args = {} } = {}) {
22
38
  defaultCrud.list = list;
23
39
  Object.assign(defaultCrud.args, args);
@@ -31,7 +47,10 @@ export function useListInstances(listInstanceArgs) {
31
47
  return instances;
32
48
  }
33
49
 
34
- export function useListInstance({ crudArgs, listArgs = {}, retrieveArgs = {}, functions = {} }) {
50
+ export function useListInstance({ props, functions = {} }) {
51
+ if (!props) {
52
+ throw new ListError(`useListInstance requires props`);
53
+ }
35
54
  // ### touching the _objectsMap or _objectsProxy directly will not trigger reactivity ###
36
55
  const _objectsMap = new Map(); // maps are ordered, if you don't clear lists, you need to insert pages in order.
37
56
  // ### touching the _objectsMap or _objectsProxy directly will not trigger reactivity ###
@@ -71,25 +90,28 @@ export function useListInstance({ crudArgs, listArgs = {}, retrieveArgs = {}, fu
71
90
  args: {},
72
91
  list: undefined,
73
92
  },
74
- retrieveArgs,
75
- listArgs,
93
+ retrieveArgs: toRef(props, "retrieveArgs"),
94
+ listArgs: toRef(props, "listArgs"),
76
95
  objects: _objectsProxy,
77
96
  loading: undefined,
78
97
  errored: false,
79
98
  error: null,
80
99
  });
81
- // prevent linking of all instances to the same default .args object
82
- Object.assign(state.crud, cloneDeep(defaultCrud));
83
- if (crudArgs) {
84
- addOrUpdateReactiveObject(state.crud.args, crudArgs);
85
- }
86
- for (const [key, value] of Object.entries(functions)) {
87
- if (isFunction(value) && key in state.crud) {
88
- state.crud[key] = value;
89
- } else {
90
- throw ListError(`Invalid function "${key}" for useListInstance: invalid key or not a function.`);
100
+ const es = effectScope();
101
+ watchEffect(() => {
102
+ // prevent linking of all instances to the same default .args object
103
+ Object.assign(state.crud, cloneDeep(defaultCrud));
104
+ if (props.crudArgs) {
105
+ addOrUpdateReactiveObject(state.crud.args, props.crudArgs);
91
106
  }
92
- }
107
+ for (const [key, value] of Object.entries(functions)) {
108
+ if (isFunction(value) && key in state.crud) {
109
+ state.crud[key] = value;
110
+ } else {
111
+ throw ListError(`Invalid function "${key}" for useListInstance: invalid key or not a function.`);
112
+ }
113
+ }
114
+ });
93
115
 
94
116
  const defaultPageCallback = (newObjects) => {
95
117
  newObjects.forEach((newObject) => {
@@ -191,12 +213,8 @@ export function useListInstance({ crudArgs, listArgs = {}, retrieveArgs = {}, fu
191
213
  state.error = null;
192
214
  }
193
215
 
194
- const es = effectScope();
195
-
196
- es.run(() => {
197
- state.objectsInOrder = computed(() => Object.values(state.objects));
198
- state.order = computed(() => Object.keys(state.objects));
199
- });
216
+ state.objectsInOrder = computed(() => Object.values(state.objects));
217
+ state.order = computed(() => Object.keys(state.objects));
200
218
 
201
219
  const returnedObject = {
202
220
  state,
@@ -1,4 +1,6 @@
1
1
  import { keyDiff, loadingCombine } from "../utils";
2
+ import { listInstanceStateKeys } from "./listInstance";
3
+ import { listSubscriptionStateKeys } from "./listSubscription";
2
4
  import { useWatchesRunning } from "./watchesRunning";
3
5
  import get from "lodash-es/get";
4
6
  import isArray from "lodash-es/isArray";
@@ -6,6 +8,13 @@ import isEmpty from "lodash-es/isEmpty";
6
8
  import isUndefined from "lodash-es/isUndefined";
7
9
  import { computed, effectScope, onScopeDispose, reactive, toRef, unref, watch } from "vue";
8
10
 
11
+ export const listRelatedStateKeys = [
12
+ "relatedObjects",
13
+ "relatedObjectsRules",
14
+ "relatedObjectsWatchRunning",
15
+ "relatedObjectsParentStateObjectsWatchRunning",
16
+ ];
17
+
9
18
  export function useListRelateds(instances, args) {
10
19
  for (const [key, value] of Object.entries(args)) {
11
20
  useListRelated({
@@ -15,45 +24,34 @@ export function useListRelateds(instances, args) {
15
24
  }
16
25
  }
17
26
 
18
- export function useListRelated({
19
- parentState,
20
- relatedObjectsRules,
21
- relatedObjectsPropertyName = "relatedObjects", // NOT REACTIVE
22
- passThroughPropertyNames = ["calculatedObjects", "totalRecords", "totalPages", "perPage"], // NOT REACTIVE
23
- }) {
27
+ export function useListRelated({ parentState, relatedObjectsRules }) {
24
28
  const state = reactive({
25
29
  relatedObjectsRules: relatedObjectsRules,
26
- relatedObjectsObjects: {},
27
- parentStateObjectsWatchRunning: false,
30
+ relatedObjects: {},
31
+ relatedObjectsParentStateObjectsWatchRunning: false,
28
32
  relatedObjectsWatchRunning: false,
29
33
  });
30
34
  const relatedObjectsEffectScopes = {};
31
35
 
32
- // don't change relatedObjectsPropertyName on us or it will break
33
- const ropn = relatedObjectsPropertyName + "";
34
-
35
36
  function parentStateObjectsWatch() {
36
- const { addedKeys, removedKeys } = keyDiff(
37
- Object.keys(parentState.objects),
38
- Object.keys(state.relatedObjectsObjects)
39
- );
37
+ const { addedKeys, removedKeys } = keyDiff(Object.keys(parentState.objects), Object.keys(state.relatedObjects));
40
38
  for (const removedKey of removedKeys) {
41
- delete state.relatedObjectsObjects[removedKey];
39
+ delete state.relatedObjects[removedKey];
42
40
  if (relatedObjectsEffectScopes[removedKey]) {
43
41
  relatedObjectsEffectScopes[removedKey].stop();
44
42
  delete relatedObjectsEffectScopes[removedKey];
45
43
  }
46
44
  }
47
45
  for (const addedKey of addedKeys) {
48
- state.relatedObjectsObjects[addedKey] = {};
46
+ state.relatedObjects[addedKey] = {};
49
47
  }
50
- state.parentStateObjectsWatchRunning = false;
48
+ state.relatedObjectsParentStateObjectsWatchRunning = false;
51
49
  }
52
50
 
53
51
  function relatedObjectsWatch() {
54
52
  const relatedObjectsRulesIsEmpty = !state.relatedObjectsRules || isEmpty(state.relatedObjectsRules);
55
- for (const objectKey of Object.keys(state.relatedObjectsObjects)) {
56
- const relatedObjectsObject = state.relatedObjectsObjects[objectKey];
53
+ for (const objectKey of Object.keys(state.relatedObjects)) {
54
+ const relatedObjectsObject = state.relatedObjects[objectKey];
57
55
  const originalObject = parentState.objects[objectKey];
58
56
  let removedRuleKeys, addedRuleKeys;
59
57
  if (!relatedObjectsRulesIsEmpty) {
@@ -103,24 +101,17 @@ export function useListRelated({
103
101
  const es = effectScope();
104
102
 
105
103
  es.run(() => {
106
- state.loading = toRef(parentState, "loading");
107
- state.errored = toRef(parentState, "errored");
108
- state.error = toRef(parentState, "error");
109
-
110
- state.retrieveArgs = toRef(parentState, "retrieveArgs");
111
- state.listArgs = toRef(parentState, "listArgs");
112
- state.order = toRef(parentState, "order");
113
- state.objects = toRef(parentState, "objects");
114
- state.objectsInOrder = toRef(parentState, "objectsInOrder");
115
- state[ropn] = toRef(state, "relatedObjectsObjects");
116
- for (let key of passThroughPropertyNames) {
104
+ for (const key of listInstanceStateKeys) {
105
+ state[key] = toRef(parentState, key);
106
+ }
107
+ for (const key of listSubscriptionStateKeys) {
117
108
  state[key] = toRef(parentState, key);
118
109
  }
119
110
 
120
111
  watch(() => Object.keys(parentState.objects), parentStateObjectsWatch, { immediate: true });
121
112
  watch(
122
113
  [
123
- () => Object.keys(state.relatedObjectsObjects),
114
+ () => Object.keys(state.relatedObjects),
124
115
  () => (state.relatedObjectsRules ? Object.keys(state.relatedObjectsRules) : state.relatedObjectsRules),
125
116
  ],
126
117
  relatedObjectsWatch,
@@ -134,7 +125,7 @@ export function useListRelated({
134
125
  ),
135
126
  ],
136
127
  watchSentinelRefs: [
137
- toRef(state, "parentStateObjectsWatchRunning"),
128
+ toRef(state, "relatedObjectsParentStateObjectsWatchRunning"),
138
129
  toRef(state, "relatedObjectsWatchRunning"),
139
130
  ],
140
131
  });
@@ -1,6 +1,6 @@
1
1
  import { loadingCombine } from "../utils/loadingCombine";
2
2
  import { useCancellableIntent } from "./cancellableIntent";
3
- import { useListInstance } from "./listInstance";
3
+ import { listInstanceStateKeys, useListInstance } from "./listInstance";
4
4
  import inspect from "browser-util-inspect";
5
5
  import cloneDeep from "lodash-es/cloneDeep";
6
6
  import isEmpty from "lodash-es/isEmpty";
@@ -18,6 +18,15 @@ const defaultCrud = {
18
18
  subscribe: undefined,
19
19
  };
20
20
 
21
+ export const listSubscriptionStateKeys = [
22
+ "subscriptionLoading",
23
+ "subscriptionErrored",
24
+ "subscriptionError",
25
+ "intendToList",
26
+ "intendToSubscribe",
27
+ "subscribed",
28
+ ];
29
+
21
30
  export function setListSubscriptionCrud({ subscribe }) {
22
31
  defaultCrud.subscribe = subscribe;
23
32
  }
@@ -30,15 +39,17 @@ export function useListSubscriptions(args, listInstances = {}) {
30
39
  return subscriptions;
31
40
  }
32
41
 
33
- export function useListSubscription({
34
- listInstance,
35
- crudArgs,
36
- listArgs,
37
- retrieveArgs,
38
- passThroughPropertyNames = ["totalRecords", "totalPages", "perPage"],
39
- }) {
42
+ export function useListSubscription({ listInstance, props, functions }) {
43
+ if (!listInstance && !props) {
44
+ throw new ListSubscriptionError("useListSubscription should be passed listInstance or props and crudArgs.");
45
+ }
46
+ if (listInstance && props) {
47
+ throw new ListSubscriptionError(
48
+ "useListSubscription should be passed listInstance or props and crudArgs, not both."
49
+ );
50
+ }
40
51
  if (!listInstance) {
41
- listInstance = useListInstance({ crudArgs, listArgs, retrieveArgs });
52
+ listInstance = useListInstance({ props, functions });
42
53
  }
43
54
  if (!listInstance.state.crud.subscribe) {
44
55
  listInstance.state.crud.subscribe = defaultCrud.subscribe;
@@ -152,12 +163,7 @@ export function useListSubscription({
152
163
  state.errored = computed(() => parentState.errored || state.subscriptionErrored);
153
164
  state.error = computed(() => parentState.error || state.subscriptionError);
154
165
 
155
- state.retrieveArgs = computed(() => parentState.retrieveArgs);
156
- state.listArgs = computed(() => parentState.listArgs);
157
- state.objects = toRef(parentState, "objects");
158
- state.order = toRef(parentState, "order");
159
- state.objectsInOrder = toRef(parentState, "objectsInOrder");
160
- for (let key of passThroughPropertyNames) {
166
+ for (const key of listInstanceStateKeys.filter((key) => !["loading", "errored", "error"].includes(key))) {
161
167
  state[key] = toRef(parentState, key);
162
168
  }
163
169
 
package/use/object.js CHANGED
@@ -2,11 +2,11 @@ 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, shallowReactive, shallowReadonly, toRef } from "vue";
5
+ import { reactive, shallowReadonly, toRef } from "vue";
6
6
 
7
7
  // Manages a chain of useObject* functions
8
8
  export const useObject = ({ props, functions }) => {
9
- const managed = shallowReactive({
9
+ const managed = reactive({
10
10
  objectInstance: null,
11
11
  objectSubscription: null,
12
12
  objectRelated: null,
@@ -32,8 +32,8 @@ export const useObject = ({ props, functions }) => {
32
32
  parentState: managed.objectRelated.state,
33
33
  calculatedObjectRules: toRef(props, "calculatedObjectRules"),
34
34
  });
35
- return shallowReactive({
35
+ return reactive({
36
36
  managed: shallowReadonly(managed),
37
- state: reactive(managed.objectCalculated.state),
37
+ state: managed.objectCalculated.state,
38
38
  });
39
39
  };
@@ -121,10 +121,10 @@ export function useObjectCalculated({
121
121
  }
122
122
  });
123
123
  });
124
- return {
124
+ return reactive({
125
125
  state,
126
126
  parentState,
127
127
  watchesRunning,
128
128
  effectScope: es,
129
- };
129
+ });
130
130
  }
@@ -1,7 +1,7 @@
1
1
  import { addOrUpdateReactiveObject, assignReactiveObject } from "../utils";
2
2
  import cloneDeep from "lodash-es/cloneDeep";
3
3
  import isFunction from "lodash-es/isFunction";
4
- import { reactive, shallowReactive, toRef } from "vue";
4
+ import { reactive, toRef } from "vue";
5
5
 
6
6
  export class ObjectError extends Error {
7
7
  constructor(message) {
@@ -222,7 +222,7 @@ export function useObjectInstance({ props, functions = {} }) {
222
222
  state.error = null;
223
223
  }
224
224
 
225
- return shallowReactive({
225
+ return reactive({
226
226
  state,
227
227
  retrieve,
228
228
  create,
@@ -119,10 +119,10 @@ export function useObjectRelated({
119
119
  });
120
120
  });
121
121
 
122
- return {
122
+ return reactive({
123
123
  state,
124
124
  parentState,
125
125
  watchesRunning,
126
126
  effectScope: es,
127
- };
127
+ });
128
128
  }
@@ -1,7 +1,7 @@
1
1
  import { assignReactiveObject, loadingCombine } from "../utils";
2
2
  import { useCancellableIntent } from "./cancellableIntent";
3
3
  import { useObjectInstance } from "./objectInstance";
4
- import { computed, effectScope, reactive, shallowReactive, toRef } from "vue";
4
+ import { computed, effectScope, reactive, toRef } from "vue";
5
5
 
6
6
  export class ObjectSubscriptionError extends Error {
7
7
  constructor(message) {
@@ -191,7 +191,7 @@ export function useObjectSubscription({
191
191
  });
192
192
  });
193
193
 
194
- return shallowReactive({
194
+ return reactive({
195
195
  state,
196
196
  objectInstance,
197
197
  subscribeIntent,