@arrai-innovations/reactive-helpers 11.4.2 → 13.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/.husky/pre-commit +0 -1
- package/.idea/codeStyles/codeStyleConfig.xml +5 -0
- package/.prettierignore +1 -0
- package/README.md +11 -10
- package/config/listCrud.js +32 -1
- package/config/objectCrud.js +47 -1
- package/docs/README.md +43 -0
- package/docs/config/listCrud.md +97 -0
- package/docs/config/objectCrud.md +123 -0
- package/docs/use/cancellableIntent.md +163 -0
- package/docs/use/combineClasses.md +52 -0
- package/docs/use/list.md +285 -0
- package/docs/use/listCalculated.md +773 -0
- package/docs/use/listFilter.md +877 -0
- package/docs/use/listInstance.md +483 -0
- package/docs/use/listKeys.md +91 -0
- package/docs/use/listRelated.md +685 -0
- package/docs/use/listSearch.md +889 -0
- package/docs/use/listSort.md +1144 -0
- package/docs/use/listSubscription.md +379 -0
- package/docs/use/loadingError.md +21 -0
- package/docs/use/object.md +437 -0
- package/docs/use/objectCalculated.md +606 -0
- package/docs/use/objectInstance.md +486 -0
- package/docs/use/objectRelated.md +588 -0
- package/docs/use/objectSubscription.md +459 -0
- package/docs/use/paginatedListInstance.md +147 -0
- package/docs/use/search.md +311 -0
- package/docs/use/watchesRunning.md +80 -0
- package/docs/utils/assignReactiveObject.md +351 -0
- package/docs/utils/classes.md +100 -0
- package/docs/utils/compact.md +57 -0
- package/docs/utils/deleteKey.md +53 -0
- package/docs/utils/flattenPaths.md +45 -0
- package/docs/utils/getFakeId.md +34 -0
- package/docs/utils/keyDiff.md +101 -0
- package/docs/utils/loadingCombine.md +28 -0
- package/docs/utils/proxyRunning.md +33 -0
- package/docs/utils/relatedCalculatedHelpers.md +75 -0
- package/docs/utils/set.md +139 -0
- package/docs/utils/transformWalk.md +33 -0
- package/docs/utils/watches.md +441 -0
- package/eslint.config.js +125 -0
- package/index.js +34 -3
- package/lint-staged.config.js +5 -1
- package/makeTypeDoc.sh +25 -0
- package/package.json +27 -19
- package/tests/unit/config/listCrud.spec.js +5 -0
- package/tests/unit/config/objectCrud.spec.js +5 -0
- package/tests/unit/crudPromise.js +22 -3
- package/tests/unit/mockOnUnmounted.js +1 -1
- package/tests/unit/use/cancellableIntent.spec.js +2 -0
- package/tests/unit/use/listCalculated.spec.js +4 -3
- package/tests/unit/use/listFilter.spec.js +11 -7
- package/tests/unit/use/listInstance.spec.js +32 -14
- package/tests/unit/use/listRelated.spec.js +3 -2
- package/tests/unit/use/listSearch.spec.js +9 -7
- package/tests/unit/use/listSort.spec.js +29 -22
- package/tests/unit/use/listSubscription.spec.js +11 -5
- package/tests/unit/use/objectInstance.spec.js +15 -2
- package/tests/unit/use/objectSubscription.spec.js +31 -16
- package/tests/unit/use/search.spec.js +2 -2
- package/tests/unit/utils/assignReactiveObject.spec.js +21 -13
- package/tests/unit/utils/classes.spec.js +7 -6
- package/tests/unit/utils/watches.spec.js +4 -4
- package/tsconfig.json +19 -0
- package/typedoc-local-plugins/customize-output.js +13 -0
- package/typedoc.json +12 -0
- package/use/cancellableIntent.js +73 -2
- package/use/combineClasses.js +41 -31
- package/use/list.js +139 -5
- package/use/listCalculated.js +175 -10
- package/use/listFilter.js +175 -21
- package/use/listInstance.js +215 -94
- package/use/listRelated.js +260 -72
- package/use/listSearch.js +178 -57
- package/use/listSort.js +188 -21
- package/use/listSubscription.js +211 -63
- package/use/loadingError.js +43 -0
- package/use/object.js +187 -23
- package/use/objectCalculated.js +168 -16
- package/use/objectInstance.js +183 -102
- package/use/objectRelated.js +276 -84
- package/use/objectSubscription.js +169 -17
- package/use/paginatedListInstance.js +30 -1
- package/use/search.js +39 -23
- package/use/watchesRunning.js +41 -6
- package/utils/assignReactiveObject.js +139 -88
- package/utils/classes.js +57 -48
- package/utils/compact.js +28 -2
- package/utils/deleteKey.js +14 -1
- package/utils/flattenPaths.js +19 -9
- package/utils/getFakeId.js +11 -1
- package/utils/keyDiff.js +26 -35
- package/utils/loadingCombine.js +7 -4
- package/utils/proxyRunning.js +16 -8
- package/utils/relatedCalculatedHelpers.js +17 -0
- package/utils/set.js +66 -0
- package/utils/transformWalk.js +7 -6
- package/utils/watches.js +205 -71
- package/.eslintignore +0 -2
- package/.eslintrc.cjs +0 -25
- package/.jsdoc2md.json +0 -4
- package/config/index.js +0 -2
- package/docs.md +0 -1002
- package/jsdoc-to-markdown.sh +0 -16
- package/tests/unit/.eslintrc.cjs +0 -11
- package/tests/unit/config/index.spec.js +0 -18
- package/tests/unit/use/index.spec.js +0 -18
- package/tests/unit/utils/index.spec.js +0 -18
- package/use/index.js +0 -19
- package/utils/debugMessage.js +0 -209
- package/utils/debugWatch.js +0 -29
- package/utils/index.js +0 -16
- package/utils/lifecycleDebug.js +0 -126
|
@@ -0,0 +1,773 @@
|
|
|
1
|
+
[**@arrai-innovations/reactive-helpers**](../README.md) • **Docs**
|
|
2
|
+
|
|
3
|
+
***
|
|
4
|
+
|
|
5
|
+
[@arrai-innovations/reactive-helpers](../README.md) / use/listCalculated
|
|
6
|
+
|
|
7
|
+
# use/listCalculated
|
|
8
|
+
|
|
9
|
+
## Interfaces
|
|
10
|
+
|
|
11
|
+
### ListCalculatedOptions
|
|
12
|
+
|
|
13
|
+
Options to configure the behavior of the list calculated properties.
|
|
14
|
+
|
|
15
|
+
#### Properties
|
|
16
|
+
|
|
17
|
+
##### calculatedObjectsRules
|
|
18
|
+
|
|
19
|
+
> **calculatedObjectsRules**: `Ref`\<`object`\>
|
|
20
|
+
|
|
21
|
+
A reactive reference to rules used for dynamic calculations
|
|
22
|
+
within list objects. Proper setup of this reference ensures that updates are managed reactively, including deep
|
|
23
|
+
property changes.
|
|
24
|
+
|
|
25
|
+
##### parentState
|
|
26
|
+
|
|
27
|
+
> **parentState**: `object`
|
|
28
|
+
|
|
29
|
+
The parent state that interacts with the calculated objects.
|
|
30
|
+
|
|
31
|
+
###### crud
|
|
32
|
+
|
|
33
|
+
> **crud**: `object`
|
|
34
|
+
|
|
35
|
+
CRUD functions and their configurations for the list.
|
|
36
|
+
|
|
37
|
+
###### crud.args
|
|
38
|
+
|
|
39
|
+
> **args**: `any`
|
|
40
|
+
|
|
41
|
+
Arguments for the CRUD functions.
|
|
42
|
+
|
|
43
|
+
###### crud.list
|
|
44
|
+
|
|
45
|
+
> **list**: `Function`
|
|
46
|
+
|
|
47
|
+
Function to list objects.
|
|
48
|
+
|
|
49
|
+
###### error
|
|
50
|
+
|
|
51
|
+
> **error**: `Error`
|
|
52
|
+
|
|
53
|
+
The last error encountered.
|
|
54
|
+
|
|
55
|
+
###### errored
|
|
56
|
+
|
|
57
|
+
> **errored**: `boolean`
|
|
58
|
+
|
|
59
|
+
Indicates if an error occurred during the last operation.
|
|
60
|
+
|
|
61
|
+
###### fkForIdAndRule
|
|
62
|
+
|
|
63
|
+
> **fkForIdAndRule**: `object`
|
|
64
|
+
|
|
65
|
+
Maintains computed references to the foreign keys for each object ID and rule, crucial for navigating complex data relationships.
|
|
66
|
+
|
|
67
|
+
###### Index Signature
|
|
68
|
+
|
|
69
|
+
\[`id`: `string`\]: `object`
|
|
70
|
+
|
|
71
|
+
###### intendToList
|
|
72
|
+
|
|
73
|
+
> **intendToList**: `boolean`
|
|
74
|
+
|
|
75
|
+
If this is true, the list should be fetched, or re-fetched if arguments change.
|
|
76
|
+
|
|
77
|
+
###### intendToSubscribe
|
|
78
|
+
|
|
79
|
+
> **intendToSubscribe**: `boolean`
|
|
80
|
+
|
|
81
|
+
If this is true, the subscription should start or restart if arguments change.
|
|
82
|
+
|
|
83
|
+
###### listArgs
|
|
84
|
+
|
|
85
|
+
> **listArgs**: `any`
|
|
86
|
+
|
|
87
|
+
Arguments passed to the server for listing operations.
|
|
88
|
+
|
|
89
|
+
###### loading
|
|
90
|
+
|
|
91
|
+
> **loading**: `boolean`
|
|
92
|
+
|
|
93
|
+
Indicates if the list is currently loading.
|
|
94
|
+
|
|
95
|
+
###### objAndKeyForIdAndRule
|
|
96
|
+
|
|
97
|
+
> **objAndKeyForIdAndRule**: `object`
|
|
98
|
+
|
|
99
|
+
Maps each object ID and rule to a tuple consisting of the related object and its respective key, facilitating direct data manipulation.
|
|
100
|
+
|
|
101
|
+
###### Index Signature
|
|
102
|
+
|
|
103
|
+
\[`id`: `string`\]: `object`
|
|
104
|
+
|
|
105
|
+
###### objects
|
|
106
|
+
|
|
107
|
+
> **objects**: [`ObjectsById`](listInstance.md#objectsbyid)
|
|
108
|
+
|
|
109
|
+
The list objects stored by their IDs.
|
|
110
|
+
|
|
111
|
+
###### objectsInOrder
|
|
112
|
+
|
|
113
|
+
> **objectsInOrder**: [`ListObject`](listInstance.md#listobject)[]
|
|
114
|
+
|
|
115
|
+
The objects in the order specified by the list.
|
|
116
|
+
|
|
117
|
+
###### order
|
|
118
|
+
|
|
119
|
+
> **order**: `string`[]
|
|
120
|
+
|
|
121
|
+
The order of objects in the list.
|
|
122
|
+
|
|
123
|
+
###### relatedObjects
|
|
124
|
+
|
|
125
|
+
> **relatedObjects**: `object`
|
|
126
|
+
|
|
127
|
+
Stores computed references to related objects, allowing for dynamic access based on object ID and specific rules.
|
|
128
|
+
|
|
129
|
+
###### Index Signature
|
|
130
|
+
|
|
131
|
+
\[`id`: `string`\]: `object`
|
|
132
|
+
|
|
133
|
+
###### relatedObjectsParentStateObjectsWatchRunning
|
|
134
|
+
|
|
135
|
+
> **relatedObjectsParentStateObjectsWatchRunning**: `boolean`
|
|
136
|
+
|
|
137
|
+
Flags whether the watch on parent state objects is currently active, ensuring updates trigger as needed.
|
|
138
|
+
|
|
139
|
+
###### relatedObjectsRules
|
|
140
|
+
|
|
141
|
+
> **relatedObjectsRules**: `object`
|
|
142
|
+
|
|
143
|
+
Defines the rules for establishing relationships, such as foreign key links and sorting orders.
|
|
144
|
+
|
|
145
|
+
###### Index Signature
|
|
146
|
+
|
|
147
|
+
\[`rule`: `string`\]: [`ListRelatedRule`](listRelated.md#listrelatedrule)
|
|
148
|
+
|
|
149
|
+
###### relatedObjectsWatchRunning
|
|
150
|
+
|
|
151
|
+
> **relatedObjectsWatchRunning**: `boolean`
|
|
152
|
+
|
|
153
|
+
Indicates if watches on the related objects themselves are active, managing updates efficiently.
|
|
154
|
+
|
|
155
|
+
###### relatedRunning
|
|
156
|
+
|
|
157
|
+
> **relatedRunning**: `boolean`
|
|
158
|
+
|
|
159
|
+
Signals whether any computations related to object relationships are currently in progress.
|
|
160
|
+
|
|
161
|
+
###### retrieveArgs
|
|
162
|
+
|
|
163
|
+
> **retrieveArgs**: `any`
|
|
164
|
+
|
|
165
|
+
Arguments passed to the server for retrieval operations.
|
|
166
|
+
|
|
167
|
+
###### running
|
|
168
|
+
|
|
169
|
+
> **running**: `boolean`
|
|
170
|
+
|
|
171
|
+
Indicates if there are ongoing reactive updates.
|
|
172
|
+
|
|
173
|
+
###### subscribed
|
|
174
|
+
|
|
175
|
+
> **subscribed**: `boolean`
|
|
176
|
+
|
|
177
|
+
Whether the subscription is active.
|
|
178
|
+
|
|
179
|
+
###### subscriptionError
|
|
180
|
+
|
|
181
|
+
> **subscriptionError**: `Error`
|
|
182
|
+
|
|
183
|
+
The error that occurred.
|
|
184
|
+
|
|
185
|
+
###### subscriptionErrored
|
|
186
|
+
|
|
187
|
+
> **subscriptionErrored**: `boolean`
|
|
188
|
+
|
|
189
|
+
Whether the subscription has errored.
|
|
190
|
+
|
|
191
|
+
###### subscriptionLoading
|
|
192
|
+
|
|
193
|
+
> **subscriptionLoading**: `boolean`
|
|
194
|
+
|
|
195
|
+
Whether the subscription is loading.
|
|
196
|
+
|
|
197
|
+
***
|
|
198
|
+
|
|
199
|
+
### ListCalculatedProperties
|
|
200
|
+
|
|
201
|
+
#### Properties
|
|
202
|
+
|
|
203
|
+
##### effectScope
|
|
204
|
+
|
|
205
|
+
> **effectScope**: `EffectScope`
|
|
206
|
+
|
|
207
|
+
The effect scope for the list calculated property.
|
|
208
|
+
|
|
209
|
+
##### parentState
|
|
210
|
+
|
|
211
|
+
> **parentState**: `object`
|
|
212
|
+
|
|
213
|
+
The parent state object.
|
|
214
|
+
|
|
215
|
+
###### crud
|
|
216
|
+
|
|
217
|
+
> **crud**: `object`
|
|
218
|
+
|
|
219
|
+
CRUD functions and their configurations for the list.
|
|
220
|
+
|
|
221
|
+
###### crud.args
|
|
222
|
+
|
|
223
|
+
> **args**: `any`
|
|
224
|
+
|
|
225
|
+
Arguments for the CRUD functions.
|
|
226
|
+
|
|
227
|
+
###### crud.list
|
|
228
|
+
|
|
229
|
+
> **list**: `Function`
|
|
230
|
+
|
|
231
|
+
Function to list objects.
|
|
232
|
+
|
|
233
|
+
###### error
|
|
234
|
+
|
|
235
|
+
> **error**: `Error`
|
|
236
|
+
|
|
237
|
+
The last error encountered.
|
|
238
|
+
|
|
239
|
+
###### errored
|
|
240
|
+
|
|
241
|
+
> **errored**: `boolean`
|
|
242
|
+
|
|
243
|
+
Indicates if an error occurred during the last operation.
|
|
244
|
+
|
|
245
|
+
###### fkForIdAndRule
|
|
246
|
+
|
|
247
|
+
> **fkForIdAndRule**: `object`
|
|
248
|
+
|
|
249
|
+
Maintains computed references to the foreign keys for each object ID and rule, crucial for navigating complex data relationships.
|
|
250
|
+
|
|
251
|
+
###### Index Signature
|
|
252
|
+
|
|
253
|
+
\[`id`: `string`\]: `object`
|
|
254
|
+
|
|
255
|
+
###### intendToList
|
|
256
|
+
|
|
257
|
+
> **intendToList**: `boolean`
|
|
258
|
+
|
|
259
|
+
If this is true, the list should be fetched, or re-fetched if arguments change.
|
|
260
|
+
|
|
261
|
+
###### intendToSubscribe
|
|
262
|
+
|
|
263
|
+
> **intendToSubscribe**: `boolean`
|
|
264
|
+
|
|
265
|
+
If this is true, the subscription should start or restart if arguments change.
|
|
266
|
+
|
|
267
|
+
###### listArgs
|
|
268
|
+
|
|
269
|
+
> **listArgs**: `any`
|
|
270
|
+
|
|
271
|
+
Arguments passed to the server for listing operations.
|
|
272
|
+
|
|
273
|
+
###### loading
|
|
274
|
+
|
|
275
|
+
> **loading**: `boolean`
|
|
276
|
+
|
|
277
|
+
Indicates if the list is currently loading.
|
|
278
|
+
|
|
279
|
+
###### objAndKeyForIdAndRule
|
|
280
|
+
|
|
281
|
+
> **objAndKeyForIdAndRule**: `object`
|
|
282
|
+
|
|
283
|
+
Maps each object ID and rule to a tuple consisting of the related object and its respective key, facilitating direct data manipulation.
|
|
284
|
+
|
|
285
|
+
###### Index Signature
|
|
286
|
+
|
|
287
|
+
\[`id`: `string`\]: `object`
|
|
288
|
+
|
|
289
|
+
###### objects
|
|
290
|
+
|
|
291
|
+
> **objects**: [`ObjectsById`](listInstance.md#objectsbyid)
|
|
292
|
+
|
|
293
|
+
The list objects stored by their IDs.
|
|
294
|
+
|
|
295
|
+
###### objectsInOrder
|
|
296
|
+
|
|
297
|
+
> **objectsInOrder**: [`ListObject`](listInstance.md#listobject)[]
|
|
298
|
+
|
|
299
|
+
The objects in the order specified by the list.
|
|
300
|
+
|
|
301
|
+
###### order
|
|
302
|
+
|
|
303
|
+
> **order**: `string`[]
|
|
304
|
+
|
|
305
|
+
The order of objects in the list.
|
|
306
|
+
|
|
307
|
+
###### relatedObjects
|
|
308
|
+
|
|
309
|
+
> **relatedObjects**: `object`
|
|
310
|
+
|
|
311
|
+
Stores computed references to related objects, allowing for dynamic access based on object ID and specific rules.
|
|
312
|
+
|
|
313
|
+
###### Index Signature
|
|
314
|
+
|
|
315
|
+
\[`id`: `string`\]: `object`
|
|
316
|
+
|
|
317
|
+
###### relatedObjectsParentStateObjectsWatchRunning
|
|
318
|
+
|
|
319
|
+
> **relatedObjectsParentStateObjectsWatchRunning**: `boolean`
|
|
320
|
+
|
|
321
|
+
Flags whether the watch on parent state objects is currently active, ensuring updates trigger as needed.
|
|
322
|
+
|
|
323
|
+
###### relatedObjectsRules
|
|
324
|
+
|
|
325
|
+
> **relatedObjectsRules**: `object`
|
|
326
|
+
|
|
327
|
+
Defines the rules for establishing relationships, such as foreign key links and sorting orders.
|
|
328
|
+
|
|
329
|
+
###### Index Signature
|
|
330
|
+
|
|
331
|
+
\[`rule`: `string`\]: [`ListRelatedRule`](listRelated.md#listrelatedrule)
|
|
332
|
+
|
|
333
|
+
###### relatedObjectsWatchRunning
|
|
334
|
+
|
|
335
|
+
> **relatedObjectsWatchRunning**: `boolean`
|
|
336
|
+
|
|
337
|
+
Indicates if watches on the related objects themselves are active, managing updates efficiently.
|
|
338
|
+
|
|
339
|
+
###### relatedRunning
|
|
340
|
+
|
|
341
|
+
> **relatedRunning**: `boolean`
|
|
342
|
+
|
|
343
|
+
Signals whether any computations related to object relationships are currently in progress.
|
|
344
|
+
|
|
345
|
+
###### retrieveArgs
|
|
346
|
+
|
|
347
|
+
> **retrieveArgs**: `any`
|
|
348
|
+
|
|
349
|
+
Arguments passed to the server for retrieval operations.
|
|
350
|
+
|
|
351
|
+
###### running
|
|
352
|
+
|
|
353
|
+
> **running**: `boolean`
|
|
354
|
+
|
|
355
|
+
Indicates if there are ongoing reactive updates.
|
|
356
|
+
|
|
357
|
+
###### subscribed
|
|
358
|
+
|
|
359
|
+
> **subscribed**: `boolean`
|
|
360
|
+
|
|
361
|
+
Whether the subscription is active.
|
|
362
|
+
|
|
363
|
+
###### subscriptionError
|
|
364
|
+
|
|
365
|
+
> **subscriptionError**: `Error`
|
|
366
|
+
|
|
367
|
+
The error that occurred.
|
|
368
|
+
|
|
369
|
+
###### subscriptionErrored
|
|
370
|
+
|
|
371
|
+
> **subscriptionErrored**: `boolean`
|
|
372
|
+
|
|
373
|
+
Whether the subscription has errored.
|
|
374
|
+
|
|
375
|
+
###### subscriptionLoading
|
|
376
|
+
|
|
377
|
+
> **subscriptionLoading**: `boolean`
|
|
378
|
+
|
|
379
|
+
Whether the subscription is loading.
|
|
380
|
+
|
|
381
|
+
##### state
|
|
382
|
+
|
|
383
|
+
> **state**: `object`
|
|
384
|
+
|
|
385
|
+
The state for the list calculated property.
|
|
386
|
+
|
|
387
|
+
###### calculatedObjects
|
|
388
|
+
|
|
389
|
+
> **calculatedObjects**: `object`
|
|
390
|
+
|
|
391
|
+
The calculated objects.
|
|
392
|
+
|
|
393
|
+
###### Index Signature
|
|
394
|
+
|
|
395
|
+
\[`id`: `string`\]: `object`
|
|
396
|
+
|
|
397
|
+
###### calculatedObjectsParentStateObjectsWatchRunning
|
|
398
|
+
|
|
399
|
+
> **calculatedObjectsParentStateObjectsWatchRunning**: `boolean`
|
|
400
|
+
|
|
401
|
+
Whether the parent state objects watch is running.
|
|
402
|
+
|
|
403
|
+
###### calculatedObjectsRules
|
|
404
|
+
|
|
405
|
+
> **calculatedObjectsRules**: `object`
|
|
406
|
+
|
|
407
|
+
The rules for the calculated objects.
|
|
408
|
+
|
|
409
|
+
###### Index Signature
|
|
410
|
+
|
|
411
|
+
\[`rule`: `string`\]: (`object`, `relatedObject`, `calculatedObjects`) => `any`
|
|
412
|
+
|
|
413
|
+
###### calculatedObjectsWatchRunning
|
|
414
|
+
|
|
415
|
+
> **calculatedObjectsWatchRunning**: `boolean`
|
|
416
|
+
|
|
417
|
+
Whether the calculated objects watch is running.
|
|
418
|
+
|
|
419
|
+
###### calculatedRunning
|
|
420
|
+
|
|
421
|
+
> **calculatedRunning**: `boolean`
|
|
422
|
+
|
|
423
|
+
Whether the calculated properties are running.
|
|
424
|
+
|
|
425
|
+
###### crud
|
|
426
|
+
|
|
427
|
+
> **crud**: `object`
|
|
428
|
+
|
|
429
|
+
CRUD functions and their configurations for the list.
|
|
430
|
+
|
|
431
|
+
###### crud.args
|
|
432
|
+
|
|
433
|
+
> **args**: `any`
|
|
434
|
+
|
|
435
|
+
Arguments for the CRUD functions.
|
|
436
|
+
|
|
437
|
+
###### crud.list
|
|
438
|
+
|
|
439
|
+
> **list**: `Function`
|
|
440
|
+
|
|
441
|
+
Function to list objects.
|
|
442
|
+
|
|
443
|
+
###### error
|
|
444
|
+
|
|
445
|
+
> **error**: `Error`
|
|
446
|
+
|
|
447
|
+
The last error encountered.
|
|
448
|
+
|
|
449
|
+
###### errored
|
|
450
|
+
|
|
451
|
+
> **errored**: `boolean`
|
|
452
|
+
|
|
453
|
+
Indicates if an error occurred during the last operation.
|
|
454
|
+
|
|
455
|
+
###### fkForIdAndRule
|
|
456
|
+
|
|
457
|
+
> **fkForIdAndRule**: `object`
|
|
458
|
+
|
|
459
|
+
Maintains computed references to the foreign keys for each object ID and rule, crucial for navigating complex data relationships.
|
|
460
|
+
|
|
461
|
+
###### Index Signature
|
|
462
|
+
|
|
463
|
+
\[`id`: `string`\]: `object`
|
|
464
|
+
|
|
465
|
+
###### intendToList
|
|
466
|
+
|
|
467
|
+
> **intendToList**: `boolean`
|
|
468
|
+
|
|
469
|
+
If this is true, the list should be fetched, or re-fetched if arguments change.
|
|
470
|
+
|
|
471
|
+
###### intendToSubscribe
|
|
472
|
+
|
|
473
|
+
> **intendToSubscribe**: `boolean`
|
|
474
|
+
|
|
475
|
+
If this is true, the subscription should start or restart if arguments change.
|
|
476
|
+
|
|
477
|
+
###### listArgs
|
|
478
|
+
|
|
479
|
+
> **listArgs**: `any`
|
|
480
|
+
|
|
481
|
+
Arguments passed to the server for listing operations.
|
|
482
|
+
|
|
483
|
+
###### loading
|
|
484
|
+
|
|
485
|
+
> **loading**: `boolean`
|
|
486
|
+
|
|
487
|
+
Indicates if the list is currently loading.
|
|
488
|
+
|
|
489
|
+
###### objAndKeyForIdAndRule
|
|
490
|
+
|
|
491
|
+
> **objAndKeyForIdAndRule**: `object`
|
|
492
|
+
|
|
493
|
+
Maps each object ID and rule to a tuple consisting of the related object and its respective key, facilitating direct data manipulation.
|
|
494
|
+
|
|
495
|
+
###### Index Signature
|
|
496
|
+
|
|
497
|
+
\[`id`: `string`\]: `object`
|
|
498
|
+
|
|
499
|
+
###### objects
|
|
500
|
+
|
|
501
|
+
> **objects**: [`ObjectsById`](listInstance.md#objectsbyid)
|
|
502
|
+
|
|
503
|
+
The list objects stored by their IDs.
|
|
504
|
+
|
|
505
|
+
###### objectsInOrder
|
|
506
|
+
|
|
507
|
+
> **objectsInOrder**: [`ListObject`](listInstance.md#listobject)[]
|
|
508
|
+
|
|
509
|
+
The objects in the order specified by the list.
|
|
510
|
+
|
|
511
|
+
###### order
|
|
512
|
+
|
|
513
|
+
> **order**: `string`[]
|
|
514
|
+
|
|
515
|
+
The order of objects in the list.
|
|
516
|
+
|
|
517
|
+
###### relatedObjects
|
|
518
|
+
|
|
519
|
+
> **relatedObjects**: `object`
|
|
520
|
+
|
|
521
|
+
Stores computed references to related objects, allowing for dynamic access based on object ID and specific rules.
|
|
522
|
+
|
|
523
|
+
###### Index Signature
|
|
524
|
+
|
|
525
|
+
\[`id`: `string`\]: `object`
|
|
526
|
+
|
|
527
|
+
###### relatedObjectsParentStateObjectsWatchRunning
|
|
528
|
+
|
|
529
|
+
> **relatedObjectsParentStateObjectsWatchRunning**: `boolean`
|
|
530
|
+
|
|
531
|
+
Flags whether the watch on parent state objects is currently active, ensuring updates trigger as needed.
|
|
532
|
+
|
|
533
|
+
###### relatedObjectsRules
|
|
534
|
+
|
|
535
|
+
> **relatedObjectsRules**: `object`
|
|
536
|
+
|
|
537
|
+
Defines the rules for establishing relationships, such as foreign key links and sorting orders.
|
|
538
|
+
|
|
539
|
+
###### Index Signature
|
|
540
|
+
|
|
541
|
+
\[`rule`: `string`\]: [`ListRelatedRule`](listRelated.md#listrelatedrule)
|
|
542
|
+
|
|
543
|
+
###### relatedObjectsWatchRunning
|
|
544
|
+
|
|
545
|
+
> **relatedObjectsWatchRunning**: `boolean`
|
|
546
|
+
|
|
547
|
+
Indicates if watches on the related objects themselves are active, managing updates efficiently.
|
|
548
|
+
|
|
549
|
+
###### relatedRunning
|
|
550
|
+
|
|
551
|
+
> **relatedRunning**: `boolean`
|
|
552
|
+
|
|
553
|
+
Signals whether any computations related to object relationships are currently in progress.
|
|
554
|
+
|
|
555
|
+
###### retrieveArgs
|
|
556
|
+
|
|
557
|
+
> **retrieveArgs**: `any`
|
|
558
|
+
|
|
559
|
+
Arguments passed to the server for retrieval operations.
|
|
560
|
+
|
|
561
|
+
###### running
|
|
562
|
+
|
|
563
|
+
> **running**: `boolean`
|
|
564
|
+
|
|
565
|
+
Indicates if there are ongoing reactive updates.
|
|
566
|
+
|
|
567
|
+
###### subscribed
|
|
568
|
+
|
|
569
|
+
> **subscribed**: `boolean`
|
|
570
|
+
|
|
571
|
+
Whether the subscription is active.
|
|
572
|
+
|
|
573
|
+
###### subscriptionError
|
|
574
|
+
|
|
575
|
+
> **subscriptionError**: `Error`
|
|
576
|
+
|
|
577
|
+
The error that occurred.
|
|
578
|
+
|
|
579
|
+
###### subscriptionErrored
|
|
580
|
+
|
|
581
|
+
> **subscriptionErrored**: `boolean`
|
|
582
|
+
|
|
583
|
+
Whether the subscription has errored.
|
|
584
|
+
|
|
585
|
+
###### subscriptionLoading
|
|
586
|
+
|
|
587
|
+
> **subscriptionLoading**: `boolean`
|
|
588
|
+
|
|
589
|
+
Whether the subscription is loading.
|
|
590
|
+
|
|
591
|
+
##### watchesRunning
|
|
592
|
+
|
|
593
|
+
> **watchesRunning**: [`WatchesRunning`](watchesRunning.md#watchesrunning)
|
|
594
|
+
|
|
595
|
+
The watches running.
|
|
596
|
+
|
|
597
|
+
***
|
|
598
|
+
|
|
599
|
+
### ListCalculatedRawState
|
|
600
|
+
|
|
601
|
+
The raw state for a list calculated property.
|
|
602
|
+
|
|
603
|
+
#### Properties
|
|
604
|
+
|
|
605
|
+
##### calculatedObjects
|
|
606
|
+
|
|
607
|
+
> **calculatedObjects**: `object`
|
|
608
|
+
|
|
609
|
+
The calculated objects.
|
|
610
|
+
|
|
611
|
+
###### Index Signature
|
|
612
|
+
|
|
613
|
+
\[`id`: `string`\]: `object`
|
|
614
|
+
|
|
615
|
+
##### calculatedObjectsParentStateObjectsWatchRunning
|
|
616
|
+
|
|
617
|
+
> **calculatedObjectsParentStateObjectsWatchRunning**: `boolean`
|
|
618
|
+
|
|
619
|
+
Whether the parent state objects watch is running.
|
|
620
|
+
|
|
621
|
+
##### calculatedObjectsRules
|
|
622
|
+
|
|
623
|
+
> **calculatedObjectsRules**: `Ref`\<`object`\>
|
|
624
|
+
|
|
625
|
+
The rules for the calculated objects.
|
|
626
|
+
|
|
627
|
+
##### calculatedObjectsWatchRunning
|
|
628
|
+
|
|
629
|
+
> **calculatedObjectsWatchRunning**: `boolean`
|
|
630
|
+
|
|
631
|
+
Whether the calculated objects watch is running.
|
|
632
|
+
|
|
633
|
+
##### calculatedRunning
|
|
634
|
+
|
|
635
|
+
> **calculatedRunning**: `boolean`
|
|
636
|
+
|
|
637
|
+
Whether the calculated properties are running.
|
|
638
|
+
|
|
639
|
+
##### running
|
|
640
|
+
|
|
641
|
+
> **running**: `Ref`\<`boolean`\>
|
|
642
|
+
|
|
643
|
+
Whether the list is running.
|
|
644
|
+
|
|
645
|
+
## Type Aliases
|
|
646
|
+
|
|
647
|
+
### ListCalculated
|
|
648
|
+
|
|
649
|
+
> **ListCalculated**\<\>: [`ListCalculatedProperties`](listCalculated.md#listcalculatedproperties)
|
|
650
|
+
|
|
651
|
+
#### Type Parameters
|
|
652
|
+
|
|
653
|
+
***
|
|
654
|
+
|
|
655
|
+
### ListCalculatedParentRawState
|
|
656
|
+
|
|
657
|
+
> **ListCalculatedParentRawState**\<\>: [`use/listInstance`](listInstance.md) & `Partial`\<[`use/listSubscription`](listSubscription.md)\> & `Partial`\<[`use/listRelated`](listRelated.md)\>
|
|
658
|
+
|
|
659
|
+
#### Type Parameters
|
|
660
|
+
|
|
661
|
+
***
|
|
662
|
+
|
|
663
|
+
### ListCalculatedParentState
|
|
664
|
+
|
|
665
|
+
> **ListCalculatedParentState**\<\>: `UnwrapNestedRefs`
|
|
666
|
+
|
|
667
|
+
#### Type Parameters
|
|
668
|
+
|
|
669
|
+
***
|
|
670
|
+
|
|
671
|
+
### ListCalculatedRules
|
|
672
|
+
|
|
673
|
+
> **ListCalculatedRules**\<\>: `Ref`
|
|
674
|
+
|
|
675
|
+
#### Type Parameters
|
|
676
|
+
|
|
677
|
+
***
|
|
678
|
+
|
|
679
|
+
### ListCalculatedState
|
|
680
|
+
|
|
681
|
+
> **ListCalculatedState**\<\>: `UnwrapNestedRefs`
|
|
682
|
+
|
|
683
|
+
#### Type Parameters
|
|
684
|
+
|
|
685
|
+
## Functions
|
|
686
|
+
|
|
687
|
+
### useListCalculated()
|
|
688
|
+
|
|
689
|
+
> **useListCalculated**(`options`): [`ListCalculatedProperties`](listCalculated.md#listcalculatedproperties)
|
|
690
|
+
|
|
691
|
+
Initializes and manages a calculated properties object for lists. This function sets up reactive states and computations
|
|
692
|
+
that dynamically update as specified in `calculatedObjectsRules`. It is used to add derived properties to list items,
|
|
693
|
+
which depend on complex calculations or interactions between multiple objects in the list. These derived properties
|
|
694
|
+
are reactive and will update in real-time as the underlying data changes, which is essential for maintaining data
|
|
695
|
+
consistency in dynamic UIs.
|
|
696
|
+
|
|
697
|
+
#### Parameters
|
|
698
|
+
|
|
699
|
+
• **options**: [`ListCalculatedOptions`](listCalculated.md#listcalculatedoptions)
|
|
700
|
+
|
|
701
|
+
Configuration options including the parent state and rules for dynamically
|
|
702
|
+
generating calculated properties. This setup allows the system to handle calculations as part of the list management
|
|
703
|
+
process, ensuring that all related data is consistently updated.
|
|
704
|
+
|
|
705
|
+
#### Returns
|
|
706
|
+
|
|
707
|
+
[`ListCalculatedProperties`](listCalculated.md#listcalculatedproperties)
|
|
708
|
+
|
|
709
|
+
- A reactive instance that manages and provides access to calculated properties within the
|
|
710
|
+
list, facilitating real-time updates and complex dependency management across multiple components.
|
|
711
|
+
|
|
712
|
+
#### Example
|
|
713
|
+
|
|
714
|
+
```vue
|
|
715
|
+
<script setup>
|
|
716
|
+
import { useListSubscription, useListComputed } from "@arrai-innovations/reactive-helpers";
|
|
717
|
+
import { reactive, toRef } from "vue";
|
|
718
|
+
|
|
719
|
+
const listSubscriptionProps = reactive({
|
|
720
|
+
// whatever props you need to get the list to work with your crud implementation
|
|
721
|
+
crudArgs: {},
|
|
722
|
+
listArgs: {},
|
|
723
|
+
retrieveArgs: {},
|
|
724
|
+
intendToList: true,
|
|
725
|
+
});
|
|
726
|
+
const listSubscription = useListSubscription(listSubscriptionProps);
|
|
727
|
+
const listComputedProps = reactive({
|
|
728
|
+
parentState: listSubscription.state,
|
|
729
|
+
computedObjectsRules: {
|
|
730
|
+
someRule: (object, relatedObjects, calculatedObjects) => {
|
|
731
|
+
// some complex calculation, relatedObjects would be assuming there was a listRelated between the two
|
|
732
|
+
// calculatedObjects would be the other calculated objects in the list
|
|
733
|
+
// including yourself, so try not to create circular dependencies
|
|
734
|
+
// this is used as a computed body.
|
|
735
|
+
return object.someProperty + object.someOtherProperty;
|
|
736
|
+
}
|
|
737
|
+
},
|
|
738
|
+
});
|
|
739
|
+
const listComputed = useListComputed(listComputedProps);
|
|
740
|
+
</script>
|
|
741
|
+
<template>
|
|
742
|
+
<ul>
|
|
743
|
+
<!-- reactive list of objects, re-retrieving the list as someListFilter changes. -->
|
|
744
|
+
<li v-for="obj in listInstance.state.objectsInOrder">
|
|
745
|
+
{{ obj }}
|
|
746
|
+
<div>
|
|
747
|
+
<!-- the computed object or objects based on the rule -->
|
|
748
|
+
{{ listComputed.state.computedObjects[obj.id].someRule }}
|
|
749
|
+
</div>
|
|
750
|
+
</li>
|
|
751
|
+
</ul>
|
|
752
|
+
</template>
|
|
753
|
+
```
|
|
754
|
+
|
|
755
|
+
***
|
|
756
|
+
|
|
757
|
+
### useListCalculateds()
|
|
758
|
+
|
|
759
|
+
> **useListCalculateds**(`listCalculatedArgs`): `object`
|
|
760
|
+
|
|
761
|
+
A composable function to create multiple list calculated objects.
|
|
762
|
+
|
|
763
|
+
#### Parameters
|
|
764
|
+
|
|
765
|
+
• **listCalculatedArgs**
|
|
766
|
+
|
|
767
|
+
The arguments for the list calculated objects.
|
|
768
|
+
|
|
769
|
+
#### Returns
|
|
770
|
+
|
|
771
|
+
`object`
|
|
772
|
+
|
|
773
|
+
- The list calculated objects.
|