@livequery/client 2.0.15 → 2.0.22
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/build/Collection.d.ts +3 -0
- package/build/Collection.js +6 -12
- package/package.json +2 -2
package/build/Collection.d.ts
CHANGED
|
@@ -24,6 +24,9 @@ export type CollectionStream<T extends LivequeryBaseEntity = LivequeryBaseEntity
|
|
|
24
24
|
error?: boolean;
|
|
25
25
|
code?: string;
|
|
26
26
|
message?: string;
|
|
27
|
+
summary?: {
|
|
28
|
+
[key: string]: any;
|
|
29
|
+
};
|
|
27
30
|
};
|
|
28
31
|
export declare class CollectionObservable<T extends LivequeryBaseEntity = LivequeryBaseEntity> extends BehaviorSubject<CollectionStream<T>> {
|
|
29
32
|
#private;
|
package/build/Collection.js
CHANGED
|
@@ -9,12 +9,6 @@ export class CollectionObservable extends BehaviorSubject {
|
|
|
9
9
|
#sorters = new Array;
|
|
10
10
|
#IdMap = new Map();
|
|
11
11
|
#refs = [];
|
|
12
|
-
// $: BehaviorSubject<CollectionStream<T>> = new BehaviorSubject<CollectionStream<T>>({
|
|
13
|
-
// items: [] as SmartQueryItem<T>[],
|
|
14
|
-
// loading: false,
|
|
15
|
-
// options: {},
|
|
16
|
-
// paging: {}
|
|
17
|
-
// })
|
|
18
12
|
unsubscribe() {
|
|
19
13
|
super.unsubscribe();
|
|
20
14
|
this.#queries.forEach(s => s.unsubscribe());
|
|
@@ -52,7 +46,7 @@ export class CollectionObservable extends BehaviorSubject {
|
|
|
52
46
|
const state = this.getValue();
|
|
53
47
|
const realtime = this.collection_options.realtime ?? true;
|
|
54
48
|
const actions = { update: false, reindex: false };
|
|
55
|
-
for (const { data, error, code, message } of stream) {
|
|
49
|
+
for (const { data, error, code, message, } of stream) {
|
|
56
50
|
if (!from_local) {
|
|
57
51
|
state.loading = false;
|
|
58
52
|
actions.update = true;
|
|
@@ -64,6 +58,10 @@ export class CollectionObservable extends BehaviorSubject {
|
|
|
64
58
|
state.message = message;
|
|
65
59
|
actions.update = true;
|
|
66
60
|
}
|
|
61
|
+
if (data?.summary) {
|
|
62
|
+
state.summary = data.summary;
|
|
63
|
+
actions.update = true;
|
|
64
|
+
}
|
|
67
65
|
// Sync
|
|
68
66
|
for (const change of data?.changes || []) {
|
|
69
67
|
if (!change?.data?.id)
|
|
@@ -264,7 +262,7 @@ export class CollectionObservable extends BehaviorSubject {
|
|
|
264
262
|
})), share());
|
|
265
263
|
});
|
|
266
264
|
const first_values = merge(...queries.map(q => q.pipe(filter(r => !!r.data?.paging || !!r.error), first()))).pipe(toArray(), tap(list => this.#sync(list, false, loading))).subscribe();
|
|
267
|
-
const subscription = merge(...queries.map(q => q.pipe(skip(1)))).pipe(bufferTime(500), filter(list => list.length > 0), map(data => this.#sync(data, false, loading)), finalize(() => first_values.unsubscribe())).subscribe();
|
|
265
|
+
const subscription = merge(...queries.map(q => q.pipe(skip(1)))).pipe(bufferTime(this.collection_options?.sync_delay || 500), filter(list => list.length > 0), map(data => this.#sync(data, false, loading)), finalize(() => first_values.unsubscribe())).subscribe();
|
|
268
266
|
this.#queries.add(subscription);
|
|
269
267
|
}
|
|
270
268
|
reset() {
|
|
@@ -278,10 +276,6 @@ export class CollectionObservable extends BehaviorSubject {
|
|
|
278
276
|
const { options } = this.getValue();
|
|
279
277
|
this.fetch_data(options, 'backward');
|
|
280
278
|
}
|
|
281
|
-
// public fetch_around_cursor(cursor: string) {
|
|
282
|
-
// const state = this.$.getValue()
|
|
283
|
-
// this.fetch_data(state.options, 'both')
|
|
284
|
-
// }
|
|
285
279
|
filter(filters) {
|
|
286
280
|
this.fetch_data(filters, 'forward', true);
|
|
287
281
|
}
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"repository": {
|
|
5
5
|
"url": "https://github.com/livequery/client"
|
|
6
6
|
},
|
|
7
|
-
"version": "2.0.
|
|
7
|
+
"version": "2.0.22",
|
|
8
8
|
"description": "",
|
|
9
9
|
"main": "build/index.js",
|
|
10
10
|
"types": "build/index.d.ts",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"devDependencies": {
|
|
18
18
|
"typescript": "^5.6.3",
|
|
19
19
|
"rxjs": "^7.8.1",
|
|
20
|
-
"@livequery/types": "^2.0.
|
|
20
|
+
"@livequery/types": "^2.0.22"
|
|
21
21
|
},
|
|
22
22
|
"scripts": {
|
|
23
23
|
"test": "echo \"Error: no test specified\" && exit 1",
|