@arrai-innovations/reactive-helpers 10.4.2 → 11.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.
@@ -42,9 +42,14 @@ export function useCancellableIntent({
42
42
 
43
43
  async function cancel() {
44
44
  if (cancelFunction) {
45
- const cancelPromise = cancelFunction().catch(console.error);
46
- cancelFunction = null;
47
- return cancelPromise;
45
+ return cancelFunction()
46
+ .catch(console.error)
47
+ .finally(() => {
48
+ if (!state.clearActiveOnResolved) {
49
+ cancelFunction = null;
50
+ state.activeCount--;
51
+ }
52
+ });
48
53
  }
49
54
  return false;
50
55
  }
package/use/index.js CHANGED
@@ -2,9 +2,11 @@ export * from "./cancellableIntent.js";
2
2
  export * from "./combineClasses.js";
3
3
  export * from "./list.js";
4
4
  export * from "./listCalculated.js";
5
+ export * from "./listKeys.js";
5
6
  export * from "./listFilter.js";
6
7
  export * from "./listInstance.js";
7
8
  export * from "./listRelated.js";
9
+ export * from "./listSearch.js";
8
10
  export * from "./listSort.js";
9
11
  export * from "./listSubscription.js";
10
12
  export * from "./object.js";
package/use/list.js CHANGED
@@ -1,9 +1,19 @@
1
- import { useListCalculated, listCalculatedFunctions } from "./listCalculated.js";
2
- import { useListFilter, listFilterFunctions } from "./listFilter.js";
3
- import { useListInstance, listInstanceFunctions } from "./listInstance.js";
4
- import { useListRelated, listRelatedFunctions } from "./listRelated.js";
5
- import { useListSort, listSortFunctions } from "./listSort.js";
6
- import { useListSubscription, listSubscriptionFunctions } from "./listSubscription.js";
1
+ import { useListCalculated } from "./listCalculated.js";
2
+ import { useListFilter } from "./listFilter.js";
3
+ import { useListInstance } from "./listInstance.js";
4
+ import {
5
+ listSortFunctions,
6
+ listFilterFunctions,
7
+ listRelatedFunctions,
8
+ listCalculatedFunctions,
9
+ listSubscriptionFunctions,
10
+ listInstanceFunctions,
11
+ listSearchFunctions,
12
+ } from "./listKeys.js";
13
+ import { useListRelated } from "./listRelated.js";
14
+ import { useListSearch } from "./listSearch.js";
15
+ import { useListSort } from "./listSort.js";
16
+ import { useListSubscription } from "./listSubscription.js";
7
17
  import { usePagedListInstance } from "./paginatedListInstance.js";
8
18
  import { effectScope, reactive, shallowReactive, shallowReadonly, toRef } from "vue";
9
19
 
@@ -16,12 +26,23 @@ export const useLists = (listArgs) => {
16
26
  };
17
27
 
18
28
  // the big brother of useObject, managing a chain of useList* instances.
19
- export const useList = ({ props, functions = {}, paged = false, keepOldPages = false, useTextSearch = false }) => {
29
+ export const useList = ({
30
+ props,
31
+ functions = {},
32
+ paged = false,
33
+ keepOldPages = false,
34
+ searchThrottle = 500,
35
+ sortThrottleWait,
36
+ searchShowAllWhenEmpty,
37
+ }) => {
20
38
  const managed = shallowReactive({
21
39
  listInstance: null,
22
40
  listSubscription: null,
23
41
  listRelated: null,
24
42
  listCalculated: null,
43
+ listFilter: null,
44
+ listSearch: null,
45
+ listSort: null,
25
46
  });
26
47
 
27
48
  if (!("listArgs" in props)) {
@@ -58,19 +79,24 @@ export const useList = ({ props, functions = {}, paged = false, keepOldPages = f
58
79
 
59
80
  managed.listFilter = useListFilter({
60
81
  parentState: managed.listCalculated.state,
61
- useTextSearch,
62
- textSearchRules: toRef(props, "textSearchRules"),
63
- textSearchValue: toRef(props, "textSearchValue"),
64
- allowedValues: toRef(props, "allowedValues"),
65
- excludedValues: toRef(props, "excludedValues"),
66
82
  allowedFilter: toRef(props, "allowedFilter"),
67
83
  excludedFilter: toRef(props, "excludedFilter"),
68
84
  });
69
85
 
70
- managed.listSort = useListSort({
86
+ managed.listSearch = useListSearch({
71
87
  parentState: managed.listFilter.state,
88
+ props: reactive({
89
+ textSearchRules: toRef(props, "textSearchRules"),
90
+ textSearchValue: toRef(props, "textSearchValue"),
91
+ }),
92
+ throttle: searchThrottle,
93
+ showAllWhenEmpty: searchShowAllWhenEmpty,
94
+ });
95
+
96
+ managed.listSort = useListSort({
97
+ parentState: managed.listSearch.state,
72
98
  orderByRules: toRef(props, "orderByRules"),
73
- sortThrottleWait: functions.sortThrottleWait,
99
+ sortThrottleWait,
74
100
  });
75
101
  });
76
102
 
@@ -94,6 +120,7 @@ export const useList = ({ props, functions = {}, paged = false, keepOldPages = f
94
120
  [managed.listRelated, listRelatedFunctions],
95
121
  [managed.listCalculated, listCalculatedFunctions],
96
122
  [managed.listFilter, listFilterFunctions],
123
+ [managed.listSearch, listSearchFunctions],
97
124
  [managed.listSort, listSortFunctions],
98
125
  ]) {
99
126
  for (const fnName of fnNames) {
@@ -1,19 +1,28 @@
1
- import { keyDiff, loadingCombine } from "../utils/index.js";
2
- import { listInstanceStateKeys } from "./listInstance.js";
3
- import { listRelatedStateKeys } from "./listRelated.js";
4
- import { listSubscriptionStateKeys } from "./listSubscription.js";
1
+ import { keyDiff, loadingCombine, difference } from "../utils/index.js";
2
+ import {
3
+ listRelatedStateKeys,
4
+ listSubscriptionStateKeys,
5
+ listInstanceStateKeys,
6
+ listFilterStateKeys,
7
+ listCalculatedStateKeys,
8
+ listSortStateKeys,
9
+ listSearchStateKeys,
10
+ } from "./listKeys.js";
5
11
  import { useWatchesRunning } from "./watchesRunning.js";
6
12
  import isEmpty from "lodash-es/isEmpty.js";
7
13
  import { computed, effectScope, onScopeDispose, reactive, ref, toRef, unref, watch } from "vue";
8
14
 
9
- export const listCalculatedStateKeys = [
10
- "calculatedObjects",
11
- "calculatedObjectsParentStateObjectsWatchRunning",
12
- "calculatedObjectsRules",
13
- "calculatedObjectsWatchRunning",
14
- ];
15
-
16
- export const listCalculatedFunctions = [];
15
+ const parentStateKeys = difference(
16
+ new Set([
17
+ ...listInstanceStateKeys,
18
+ ...listSubscriptionStateKeys,
19
+ ...listRelatedStateKeys,
20
+ ...listFilterStateKeys,
21
+ ...listSortStateKeys,
22
+ ...listSearchStateKeys,
23
+ ]),
24
+ new Set(listCalculatedStateKeys)
25
+ );
17
26
 
18
27
  export function useListCalculateds(instances, args) {
19
28
  for (const [key, value] of Object.entries(args)) {
@@ -104,13 +113,7 @@ export function useListCalculated({ parentState, calculatedObjectsRules }) {
104
113
  const es = effectScope();
105
114
 
106
115
  es.run(() => {
107
- for (const key of listInstanceStateKeys) {
108
- state[key] = toRef(parentState, key);
109
- }
110
- for (const key of listSubscriptionStateKeys) {
111
- state[key] = toRef(parentState, key);
112
- }
113
- for (const key of listRelatedStateKeys) {
116
+ for (const key of parentStateKeys) {
114
117
  state[key] = toRef(parentState, key);
115
118
  }
116
119
 
package/use/listFilter.js CHANGED
@@ -1,29 +1,29 @@
1
+ import { assignReactiveObject, difference, loadingCombine } from "../utils/index.js";
1
2
  import { keyDiff } from "../utils/keyDiff.js";
2
- import { listCalculatedStateKeys } from "./listCalculated.js";
3
- import { listInstanceStateKeys } from "./listInstance.js";
4
- import { listRelatedStateKeys } from "./listRelated.js";
5
- import { listSubscriptionStateKeys } from "./listSubscription.js";
6
- import { useSearch } from "./search.js";
7
- import get from "lodash-es/get.js";
8
- import identity from "lodash-es/identity.js";
9
- import isEmpty from "lodash-es/isEmpty.js";
10
- import { computed, effectScope, onScopeDispose, reactive, toRef, watch, watchEffect } from "vue";
11
-
12
- export const listFilterStateKeys = [
13
- "objectIndexes",
14
- // override but not ours
15
- // "objects",
16
- "textSearchRules",
17
- "textSearchValue",
18
- "allowedValues",
19
- "excludedValues",
20
- "allowedFilter",
21
- "excludedFilter",
22
- "searched",
23
- "searching",
24
- ];
25
-
26
- export const listFilterFunctions = [];
3
+ import {
4
+ listSortStateKeys,
5
+ listFilterStateKeys,
6
+ listRelatedStateKeys,
7
+ listCalculatedStateKeys,
8
+ listSubscriptionStateKeys,
9
+ listInstanceStateKeys,
10
+ listSearchStateKeys,
11
+ } from "./listKeys.js";
12
+ import { effectScope, reactive, toRef, watch, unref, computed, nextTick } from "vue";
13
+
14
+ 3;
15
+
16
+ const parentStateKeys = difference(
17
+ new Set([
18
+ ...listInstanceStateKeys,
19
+ ...listSubscriptionStateKeys,
20
+ ...listRelatedStateKeys,
21
+ ...listCalculatedStateKeys,
22
+ ...listSortStateKeys,
23
+ ...listSearchStateKeys,
24
+ ]),
25
+ new Set(listFilterStateKeys)
26
+ );
27
27
 
28
28
  export function useListFilters(listFilterArgs, parentInstances) {
29
29
  const filters = {};
@@ -33,157 +33,131 @@ export function useListFilters(listFilterArgs, parentInstances) {
33
33
  return filters;
34
34
  }
35
35
 
36
- export function useListFilter({
37
- parentState,
38
- useTextSearch = false,
39
- textSearchRules = [],
40
- textSearchValue = "",
41
- allowedValues = {},
42
- excludedValues = {},
43
- allowedFilter,
44
- excludedFilter,
45
- customIndexOptions = {},
46
- customSearchOptions = {},
47
- }) {
36
+ const inResults = (state, object, relatedObject, calculatedObject) => {
37
+ const unrefObject = unref(object);
38
+ const unrefRelatedObject = unref(relatedObject);
39
+ const unrefCalculatedObject = unref(calculatedObject);
40
+ return !(
41
+ (state.allowedFilter && !state.allowedFilter(unrefObject, unrefRelatedObject, unrefCalculatedObject)) ||
42
+ (state.excludedFilter && state.excludedFilter(unrefObject, unrefRelatedObject, unrefCalculatedObject))
43
+ );
44
+ };
45
+
46
+ export function useListFilter({ parentState, allowedFilter, excludedFilter }) {
48
47
  const state = reactive({
49
- objectIndexes: {},
48
+ inResults: {},
50
49
  objects: {},
51
- textSearchRules,
52
- textSearchValue,
53
- allowedValues,
54
- excludedValues,
50
+ objectsInOrder: [],
51
+ order: [],
55
52
  allowedFilter,
56
53
  excludedFilter,
57
- searched: undefined,
58
- searching: undefined,
54
+ objectsWatchRunning: undefined,
55
+ resultsWatchRunning: undefined,
56
+ running: undefined,
59
57
  });
60
58
 
61
59
  const es = effectScope();
62
60
 
63
- let textSearchIndex;
61
+ const makeComputed = (key) => {
62
+ const object = toRef(parentState.objects, key);
63
+ const relatedObject = toRef(parentState.relatedObjects, key);
64
+ const calculatedObject = toRef(parentState.calculatedObjects, key);
65
+ return computed(() => inResults(state, object, relatedObject, calculatedObject));
66
+ };
64
67
 
65
- es.run(() => {
66
- for (const key of listInstanceStateKeys) {
67
- if (key === "objects") {
68
- continue;
68
+ let previousAllowedFilter = null,
69
+ previousExcludedFilter = null;
70
+
71
+ const objectsWatch = () => {
72
+ if (parentState.running) {
73
+ return;
74
+ }
75
+ state.objectsWatchRunning = true;
76
+ const allowedOrExcludedFilterChanged =
77
+ allowedFilter !== previousAllowedFilter || excludedFilter !== previousExcludedFilter;
78
+ if (!state.allowedFilter && !state.excludedFilter) {
79
+ assignReactiveObject(state.inResults, {});
80
+ assignReactiveObject(state.objects, parentState.objects);
81
+ } else if (allowedOrExcludedFilterChanged) {
82
+ // recreate all the computeds
83
+ assignReactiveObject(state.inResults, {});
84
+ for (const key of Object.keys(parentState.objects)) {
85
+ state.inResults[key] = makeComputed(key);
86
+ }
87
+ } else {
88
+ // we just need to make sure all the computeds exist that should exist
89
+ const { addedKeys, removedKeys } = keyDiff(Object.keys(parentState.objects), Object.keys(state.inResults), {
90
+ sameKeys: false,
91
+ });
92
+ for (const addedKey of addedKeys) {
93
+ state.inResults[addedKey] = makeComputed(addedKey);
94
+ }
95
+ for (const removedKey of removedKeys) {
96
+ delete state.inResults[removedKey];
69
97
  }
70
- state[key] = toRef(parentState, key);
71
98
  }
72
- for (const key of listSubscriptionStateKeys) {
73
- state[key] = toRef(parentState, key);
99
+ previousAllowedFilter = allowedFilter;
100
+ previousExcludedFilter = excludedFilter;
101
+ nextTick().then(() => {
102
+ state.objectsWatchRunning = false;
103
+ });
104
+ };
105
+
106
+ const resultsWatch = async () => {
107
+ if (parentState.running) {
108
+ return;
74
109
  }
75
- for (const key of listRelatedStateKeys) {
76
- state[key] = toRef(parentState, key);
110
+ state.resultsWatchRunning = true;
111
+ await nextTick();
112
+ if (state.allowedFilter || state.excludedFilter) {
113
+ assignReactiveObject(
114
+ state.objects,
115
+ Object.fromEntries(
116
+ Object.entries(state.inResults)
117
+ .filter(([, value]) => !!value)
118
+ .map(([id]) => [id, toRef(parentState.objects, id)])
119
+ )
120
+ );
77
121
  }
78
- for (const key of listCalculatedStateKeys) {
79
- state[key] = toRef(parentState, key);
122
+
123
+ nextTick().then(() => {
124
+ state.resultsWatchRunning = false;
125
+ });
126
+ };
127
+
128
+ const orderWatch = () => {
129
+ let desiredOrder = parentState.order.filter((id) => !!state.objects[id]),
130
+ desiredObjectsInOrder = desiredOrder.map((id) => toRef(state.objects, id));
131
+ if (!state.allowedFilter && !state.excludedFilter) {
132
+ desiredOrder = parentState.order;
133
+ desiredObjectsInOrder = parentState.objectsInOrder;
80
134
  }
81
- if (useTextSearch) {
82
- textSearchIndex = useSearch(customIndexOptions, customSearchOptions);
83
- textSearchIndex.state.search = toRef(state, "textSearchValue");
84
- state.searched = toRef(textSearchIndex.state, "searched");
85
- state.searching = toRef(textSearchIndex.state, "searching");
135
+ assignReactiveObject(state.objectsInOrder, desiredObjectsInOrder);
136
+ assignReactiveObject(state.order, desiredOrder);
137
+ };
138
+
139
+ es.run(() => {
140
+ for (const key of parentStateKeys) {
141
+ state[key] = toRef(parentState, key);
86
142
  }
87
143
 
88
- // todo: computed is not the solution here for deep reactions
89
- state.objectsInOrder = computed(() => parentState.order.map((id) => state.objects[id]).filter(identity));
90
- state.order = computed(() => state.objectsInOrder.map((object) => `${object.id}`));
91
-
92
- // todo: this huge watchEffect is fairly gross, but also doesn't watch deep similarly to computed
93
- watchEffect(() => {
94
- const allowedValuesEmpty = !state.allowedValues || isEmpty(state.allowedValues);
95
- const excludedValuesEmpty = !state.excludedValues || isEmpty(state.excludedValues);
96
- const resultsEmpty = useTextSearch
97
- ? !textSearchIndex.state.results || isEmpty(textSearchIndex.state.results)
98
- : undefined;
99
- const searched = useTextSearch ? textSearchIndex.state.searched : undefined;
100
-
101
- const inResults = (object) => {
102
- if (!allowedValuesEmpty && !state.allowedValues[object.id]) {
103
- return false;
104
- }
105
- if (!excludedValuesEmpty && state.excludedValues[object.id]) {
106
- return false;
107
- }
108
- if (state.allowedFilter && !state.allowedFilter(object)) {
109
- return false;
110
- }
111
- if (state.excludedFilter && state.excludedFilter(object)) {
112
- return false;
113
- }
114
- if (!useTextSearch) {
115
- return true;
116
- }
117
- if (!searched && resultsEmpty) {
118
- return true;
119
- }
120
- return !!textSearchIndex.state.results[object.id];
121
- };
122
- const { removedKeys, sameKeys, addedKeys } = keyDiff(
123
- Object.keys(parentState.objects),
124
- Object.keys(state.objects)
125
- );
126
- for (const removedKey of removedKeys) {
127
- delete state.objects[removedKey];
128
- }
129
- for (const addedKey of addedKeys) {
130
- if (inResults(parentState.objects[addedKey])) {
131
- state.objects[addedKey] = toRef(parentState.objects, addedKey);
132
- }
133
- }
134
- for (const sameKey of sameKeys) {
135
- if (inResults(parentState.objects[sameKey])) {
136
- if (state.objects[sameKey] !== parentState.objects[sameKey]) {
137
- state.objects[sameKey] = toRef(parentState.objects, sameKey);
138
- }
139
- } else {
140
- delete state.objects[sameKey];
141
- }
142
- }
144
+ state.running = computed(() => {
145
+ return loadingCombine(parentState.running, state.objectsWatchRunning, state.resultsWatchRunning);
143
146
  });
144
147
 
145
- if (useTextSearch) {
146
- const stopIndexWatch = {};
147
-
148
- // todo: this huge watchEffect is fairly gross, but also doesn't watch deep similarly to computed
149
- watchEffect(() => {
150
- const { removedKeys, addedKeys } = keyDiff(
151
- Object.keys(parentState.objects),
152
- Object.keys(state.objectIndexes)
153
- );
154
- for (const removedKey of removedKeys) {
155
- delete state.objectIndexes[removedKey];
156
- textSearchIndex.removeIndex(removedKey);
157
- if (stopIndexWatch[removedKey]) {
158
- stopIndexWatch[removedKey]();
159
- delete stopIndexWatch[removedKey];
160
- }
161
- }
162
- for (const addedKey of addedKeys) {
163
- state.objectIndexes[addedKey] = true;
164
- textSearchIndex.addIndex(
165
- addedKey,
166
- state.textSearchRules.map((o) => get(parentState.objects[addedKey], o)).join(" ")
167
- );
168
- stopIndexWatch[addedKey] = watch(
169
- [toRef(state, "textSearchRules"), toRef(parentState.objects, "addedKey")],
170
- (textSearchRules, object) => {
171
- textSearchIndex.updateIndex(addedKey, textSearchRules.map((o) => get(object, o)).join(" "));
172
- }
173
- );
174
- }
175
- });
176
- onScopeDispose(() => {
177
- for (const key in stopIndexWatch) {
178
- stopIndexWatch[key]();
179
- }
180
- });
181
- }
148
+ watch(toRef(state, "inResults"), resultsWatch, { deep: true });
149
+
150
+ watch(toRef(parentState, "order"), orderWatch, { deep: true, immediate: true });
151
+
152
+ watch(
153
+ [() => Object.keys(parentState.objects), toRef(state, "allowedFilter"), toRef(state, "excludedFilter")],
154
+ objectsWatch,
155
+ { immediate: true }
156
+ );
182
157
  });
183
158
  return {
184
159
  state,
185
160
  parentState,
186
- textSearchIndex,
187
161
  effectScope: es,
188
162
  };
189
163
  }
@@ -12,34 +12,6 @@ export class ListError extends Error {
12
12
  }
13
13
  }
14
14
 
15
- export const listInstanceStateKeys = [
16
- "crud",
17
- "retrieveArgs",
18
- "listArgs",
19
- "objects",
20
- "loading",
21
- "errored",
22
- "error",
23
- "objectsInOrder",
24
- "order",
25
- // when paged
26
- "totalRecords",
27
- "totalPages",
28
- "perPage",
29
- ];
30
-
31
- export const listInstanceFunctions = [
32
- "list",
33
- "addListObject",
34
- "updateListObject",
35
- "deleteListObject",
36
- "clearList",
37
- "clearError",
38
- "getFakeId",
39
- "defaultPageCallback",
40
- "pageCallback",
41
- ];
42
-
43
15
  /**
44
16
  * The configuration options used to create a list instance.
45
17
  * @typedef {object} ListInstanceOptions
@@ -0,0 +1,94 @@
1
+ export const listInstanceStateKeys = [
2
+ "crud",
3
+ "retrieveArgs",
4
+ "listArgs",
5
+ "objects",
6
+ "loading",
7
+ "errored",
8
+ "error",
9
+ "objectsInOrder",
10
+ "order",
11
+ // when paged
12
+ "totalRecords",
13
+ "totalPages",
14
+ "perPage",
15
+ ];
16
+ export const listInstanceFunctions = [
17
+ "list",
18
+ "addListObject",
19
+ "updateListObject",
20
+ "deleteListObject",
21
+ "clearList",
22
+ "clearError",
23
+ "getFakeId",
24
+ "defaultPageCallback",
25
+ "pageCallback",
26
+ ];
27
+
28
+ export const listSubscriptionStateKeys = [
29
+ "subscriptionLoading",
30
+ "subscriptionErrored",
31
+ "subscriptionError",
32
+ "intendToList",
33
+ "intendToSubscribe",
34
+ "subscribed",
35
+ ];
36
+ export const listSubscriptionFunctions = ["subscribe", "unsubscribe", "clearError"];
37
+
38
+ export const listRelatedStateKeys = [
39
+ "relatedObjects",
40
+ "relatedObjectsRules",
41
+ "relatedObjectsWatchRunning",
42
+ "relatedObjectsParentStateObjectsWatchRunning",
43
+ "running",
44
+ ];
45
+ export const listRelatedFunctions = [];
46
+
47
+ export const listCalculatedStateKeys = [
48
+ "calculatedObjects",
49
+ "calculatedObjectsParentStateObjectsWatchRunning",
50
+ "calculatedObjectsRules",
51
+ "calculatedObjectsWatchRunning",
52
+ "running",
53
+ ];
54
+ export const listCalculatedFunctions = [];
55
+
56
+ export const listFilterStateKeys = [
57
+ "objects",
58
+ "order",
59
+ "objectsInOrder",
60
+ "allowedFilter",
61
+ "excludedFilter",
62
+ "running",
63
+ "objectsWatchRunning",
64
+ "resultsWatchRunning",
65
+ ];
66
+ export const listFilterFunctions = [];
67
+
68
+ export const listSearchStateKeys = [
69
+ "objectIndexes",
70
+ "objects",
71
+ "order",
72
+ "objectsInOrder",
73
+ "textSearchRules",
74
+ "textSearchValue",
75
+ "searched",
76
+ "updateSearchIndexesRunning",
77
+ "customDocumentOptions",
78
+ "customSearchOptions",
79
+ "running",
80
+ "newSearchComputeds",
81
+ ];
82
+ export const listSearchFunctions = [];
83
+ export const listSortStateKeys = [
84
+ "orderByRules",
85
+ "order",
86
+ "objectsInOrder",
87
+ "sortCriteria",
88
+ "orderByDesc",
89
+ "sortCriteriaWatchRunning",
90
+ "sortWatchRunning",
91
+ "outstandingEffects",
92
+ "running",
93
+ ];
94
+ export const listSortFunctions = [];
@@ -1,7 +1,15 @@
1
+ import { difference } from "../utils/index.js";
1
2
  import { keyDiff } from "../utils/keyDiff.js";
2
3
  import { loadingCombine } from "../utils/loadingCombine.js";
3
- import { listInstanceStateKeys } from "./listInstance.js";
4
- import { listSubscriptionStateKeys } from "./listSubscription.js";
4
+ import {
5
+ listSubscriptionStateKeys,
6
+ listInstanceStateKeys,
7
+ listRelatedStateKeys,
8
+ listCalculatedStateKeys,
9
+ listSortStateKeys,
10
+ listFilterStateKeys,
11
+ listSearchStateKeys,
12
+ } from "./listKeys.js";
5
13
  import { useWatchesRunning } from "./watchesRunning.js";
6
14
  import get from "lodash-es/get.js";
7
15
  import identity from "lodash-es/identity.js";
@@ -11,14 +19,17 @@ import isEqual from "lodash-es/isEqual.js";
11
19
  import isUndefined from "lodash-es/isUndefined.js";
12
20
  import { computed, effectScope, onScopeDispose, reactive, toRef, unref, watch } from "vue";
13
21
 
14
- export const listRelatedStateKeys = [
15
- "relatedObjects",
16
- "relatedObjectsRules",
17
- "relatedObjectsWatchRunning",
18
- "relatedObjectsParentStateObjectsWatchRunning",
19
- ];
20
-
21
- export const listRelatedFunctions = [];
22
+ const parentStateKeys = difference(
23
+ new Set([
24
+ ...listInstanceStateKeys,
25
+ ...listSubscriptionStateKeys,
26
+ ...listCalculatedStateKeys,
27
+ ...listFilterStateKeys,
28
+ ...listSortStateKeys,
29
+ ...listSearchStateKeys,
30
+ ]),
31
+ new Set(listRelatedStateKeys)
32
+ );
22
33
 
23
34
  export function useListRelateds(instances, args) {
24
35
  for (const [key, value] of Object.entries(args)) {
@@ -151,10 +162,7 @@ export function useListRelated({ parentState, relatedObjectsRules }) {
151
162
  const es = effectScope();
152
163
 
153
164
  es.run(() => {
154
- for (const key of listInstanceStateKeys) {
155
- state[key] = toRef(parentState, key);
156
- }
157
- for (const key of listSubscriptionStateKeys) {
165
+ for (const key of parentStateKeys) {
158
166
  state[key] = toRef(parentState, key);
159
167
  }
160
168