@arrai-innovations/reactive-helpers 4.1.0 → 4.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.
- package/package.json +1 -1
- package/use/listCalculated.js +1 -1
- package/use/listRelated.js +1 -1
- package/use/listSubscription.js +28 -18
- package/use/paginatedListInstance.js +2 -2
package/package.json
CHANGED
package/use/listCalculated.js
CHANGED
|
@@ -19,7 +19,7 @@ export function useListCalculated({
|
|
|
19
19
|
parentState,
|
|
20
20
|
calculatedObjectsRules,
|
|
21
21
|
calculatedObjectsPropertyName = "calculatedObjects", // NOT REACTIVE
|
|
22
|
-
passThroughPropertyNames = ["relatedObjects"], // NOT REACTIVE
|
|
22
|
+
passThroughPropertyNames = ["relatedObjects", "totalRecords", "totalPages", "perPage"], // NOT REACTIVE
|
|
23
23
|
}) {
|
|
24
24
|
const state = reactive({
|
|
25
25
|
calculatedObjectsRules,
|
package/use/listRelated.js
CHANGED
|
@@ -16,7 +16,7 @@ export function useListRelated({
|
|
|
16
16
|
parentState,
|
|
17
17
|
relatedObjectsRules,
|
|
18
18
|
relatedObjectsPropertyName = "relatedObjects", // NOT REACTIVE
|
|
19
|
-
passThroughPropertyNames = ["calculatedObjects"], // NOT REACTIVE
|
|
19
|
+
passThroughPropertyNames = ["calculatedObjects", "totalRecords", "totalPages", "perPage"], // NOT REACTIVE
|
|
20
20
|
}) {
|
|
21
21
|
const state = reactive({
|
|
22
22
|
relatedObjectsRules: relatedObjectsRules,
|
package/use/listSubscription.js
CHANGED
|
@@ -28,13 +28,20 @@ export function useListSubscriptions(args, listInstances = {}) {
|
|
|
28
28
|
return subscriptions;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
export function useListSubscription({
|
|
31
|
+
export function useListSubscription({
|
|
32
|
+
listInstance,
|
|
33
|
+
crudArgs,
|
|
34
|
+
listArgs,
|
|
35
|
+
retrieveArgs,
|
|
36
|
+
passThroughPropertyNames = ["totalRecords", "totalPages", "perPage"],
|
|
37
|
+
}) {
|
|
32
38
|
if (!listInstance) {
|
|
33
39
|
listInstance = useListInstance({ crudArgs, listArgs, retrieveArgs });
|
|
34
40
|
}
|
|
35
41
|
if (!listInstance.state.crud.subscribe) {
|
|
36
42
|
listInstance.state.crud.subscribe = defaultCrud.subscribe;
|
|
37
43
|
}
|
|
44
|
+
const parentState = listInstance.state;
|
|
38
45
|
|
|
39
46
|
let subscribeIntent, listIntent;
|
|
40
47
|
const state = reactive({
|
|
@@ -139,23 +146,26 @@ export function useListSubscription({ listInstance, crudArgs, listArgs, retrieve
|
|
|
139
146
|
const es = effectScope();
|
|
140
147
|
|
|
141
148
|
es.run(() => {
|
|
142
|
-
state.loading = computed(() => loadingCombine(
|
|
143
|
-
state.errored = computed(() =>
|
|
144
|
-
state.error = computed(() =>
|
|
145
|
-
|
|
146
|
-
state.retrieveArgs = computed(() =>
|
|
147
|
-
state.listArgs = computed(() =>
|
|
148
|
-
state.objects = toRef(
|
|
149
|
-
state.order = toRef(
|
|
150
|
-
state.objectsInOrder = toRef(
|
|
149
|
+
state.loading = computed(() => loadingCombine(parentState.loading, state.subscriptionLoading));
|
|
150
|
+
state.errored = computed(() => parentState.errored || state.subscriptionErrored);
|
|
151
|
+
state.error = computed(() => parentState.error || state.subscriptionError);
|
|
152
|
+
|
|
153
|
+
state.retrieveArgs = computed(() => parentState.retrieveArgs);
|
|
154
|
+
state.listArgs = computed(() => parentState.listArgs);
|
|
155
|
+
state.objects = toRef(parentState, "objects");
|
|
156
|
+
state.order = toRef(parentState, "order");
|
|
157
|
+
state.objectsInOrder = toRef(parentState, "objectsInOrder");
|
|
158
|
+
for (let key in passThroughPropertyNames) {
|
|
159
|
+
state[key] = toRef(parentState, key);
|
|
160
|
+
}
|
|
151
161
|
|
|
152
162
|
subscribeIntent = useCancellableIntent({
|
|
153
163
|
awaitableWithCancel: () => {
|
|
154
164
|
// this function cannot be async, or the resulting promise will lose its .cancel() method
|
|
155
|
-
const subscribePromise =
|
|
156
|
-
crudArgs: cloneDeep(
|
|
157
|
-
listArgs: cloneDeep(
|
|
158
|
-
retrieveArgs: cloneDeep(
|
|
165
|
+
const subscribePromise = parentState.crud.subscribe({
|
|
166
|
+
crudArgs: cloneDeep(parentState.crud.args),
|
|
167
|
+
listArgs: cloneDeep(parentState.listArgs),
|
|
168
|
+
retrieveArgs: cloneDeep(parentState.retrieveArgs),
|
|
159
169
|
subscriptionEventCallback,
|
|
160
170
|
});
|
|
161
171
|
// catching makes a new promise, we need to make sure the cancel method lives on.
|
|
@@ -169,8 +179,8 @@ export function useListSubscription({ listInstance, crudArgs, listArgs, retrieve
|
|
|
169
179
|
},
|
|
170
180
|
watchArguments: reactive({
|
|
171
181
|
intendToSubscribe: toRef(state, "intendToSubscribe"),
|
|
172
|
-
listArgs: toRef(
|
|
173
|
-
retrieveArgs: toRef(
|
|
182
|
+
listArgs: toRef(parentState, "listArgs"),
|
|
183
|
+
retrieveArgs: toRef(parentState, "retrieveArgs"),
|
|
174
184
|
}),
|
|
175
185
|
clearActiveOnResolved: false,
|
|
176
186
|
});
|
|
@@ -184,8 +194,8 @@ export function useListSubscription({ listInstance, crudArgs, listArgs, retrieve
|
|
|
184
194
|
},
|
|
185
195
|
watchArguments: reactive({
|
|
186
196
|
intendToList: toRef(state, "intendToList"),
|
|
187
|
-
listArgs: toRef(
|
|
188
|
-
retrieveArgs: toRef(
|
|
197
|
+
listArgs: toRef(parentState, "listArgs"),
|
|
198
|
+
retrieveArgs: toRef(parentState, "retrieveArgs"),
|
|
189
199
|
}),
|
|
190
200
|
});
|
|
191
201
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useListInstance } from "./listInstance";
|
|
2
2
|
|
|
3
|
-
export function usePagedListInstance(
|
|
4
|
-
const listInstance = useListInstance(
|
|
3
|
+
export function usePagedListInstance(useListInstanceArgs) {
|
|
4
|
+
const listInstance = useListInstance(useListInstanceArgs);
|
|
5
5
|
|
|
6
6
|
listInstance.state.totalRecords = 0;
|
|
7
7
|
listInstance.state.totalPages = 0;
|