@dereekb/dbx-firebase 9.3.1 → 9.3.2
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/esm2020/lib/model/loader/collection.change.trigger.mjs +9 -2
- package/esm2020/lib/model/loader/collection.loader.instance.mjs +2 -1
- package/esm2020/lib/model/store/store.collection.mjs +2 -1
- package/esm2020/lib/model/store/store.document.mjs +16 -1
- package/fesm2015/dereekb-dbx-firebase.mjs +24 -1
- package/fesm2015/dereekb-dbx-firebase.mjs.map +1 -1
- package/fesm2020/dereekb-dbx-firebase.mjs +25 -1
- package/fesm2020/dereekb-dbx-firebase.mjs.map +1 -1
- package/lib/model/loader/collection.change.trigger.d.ts +4 -0
- package/lib/model/loader/collection.loader.instance.d.ts +1 -0
- package/lib/model/store/store.collection.d.ts +5 -0
- package/lib/model/store/store.document.d.ts +10 -0
- package/package.json +6 -6
|
@@ -1962,6 +1962,10 @@ class DbxFirebaseCollectionChangeTriggerInstance {
|
|
|
1962
1962
|
/**
|
|
1963
1963
|
* Creates a new DbxFirebaseCollectionChangeWatcher, set the modes to "auto", and creates a new DbxFirebaseCollectionChangeTriggerInstance.
|
|
1964
1964
|
*
|
|
1965
|
+
* If no trigger function is provided it will default to resetting the store.
|
|
1966
|
+
*
|
|
1967
|
+
* NOTE: Don't forget to initialize the DbxFirebaseCollectionChangeTriggerInstance and handle other lifecycle changes.
|
|
1968
|
+
*
|
|
1965
1969
|
* @param store
|
|
1966
1970
|
* @param triggerFunction
|
|
1967
1971
|
* @returns
|
|
@@ -1970,7 +1974,10 @@ function dbxFirebaseCollectionChangeTriggerForStore(store, triggerFunction) {
|
|
|
1970
1974
|
return dbxFirebaseCollectionChangeTrigger({
|
|
1971
1975
|
watcher: dbxFirebaseCollectionChangeWatcher(store, 'auto'),
|
|
1972
1976
|
destroyWatcherOnDestroy: true,
|
|
1973
|
-
triggerFunction
|
|
1977
|
+
triggerFunction: triggerFunction ??
|
|
1978
|
+
(() => {
|
|
1979
|
+
store.restart();
|
|
1980
|
+
})
|
|
1974
1981
|
});
|
|
1975
1982
|
}
|
|
1976
1983
|
function dbxFirebaseCollectionChangeTriggerForWatcher(watcher, triggerFunction) {
|
|
@@ -2019,6 +2026,7 @@ class DbxFirebaseCollectionLoaderInstance {
|
|
|
2019
2026
|
}), shareReplay(1));
|
|
2020
2027
|
this.accumulator$ = this.firestoreIteration$.pipe(map((x) => firebaseQueryItemAccumulator(x)), cleanupDestroyable(), shareReplay(1));
|
|
2021
2028
|
this.accumulatorItems$ = this.accumulator$.pipe(switchMap((x) => x.allItems$), shareReplay(1));
|
|
2029
|
+
this.hasDocuments$ = this.firestoreIteration$.pipe(switchMap((x) => x.firstState$.pipe(map((x) => Boolean(x.value?.length)))), shareReplay(1));
|
|
2022
2030
|
this.allDocumentRefs$ = this.snapshotAccumulatorDocumentRefs$.pipe(map((x) => x.flat()), shareReplay(1));
|
|
2023
2031
|
this.allDocuments$ = this.snapshotAccumulatorDocuments$.pipe(map((x) => x.flat()), shareReplay(1));
|
|
2024
2032
|
this.allDocumentData$ = this.accumulatorItems$.pipe(map((x) => x.flat()), shareReplay(1));
|
|
@@ -2565,6 +2573,7 @@ class AbstractDbxFirebaseCollectionStore extends LockSetComponentStore {
|
|
|
2565
2573
|
this.queryChangeWatcher$ = this.loader$.pipe(switchMap((x) => x.queryChangeWatcher$));
|
|
2566
2574
|
this.accumulator$ = this.loader$.pipe(switchMap((x) => x.accumulator$));
|
|
2567
2575
|
this.pageLoadingState$ = this.loader$.pipe(switchMap((x) => x.pageLoadingState$));
|
|
2576
|
+
this.hasDocuments$ = this.loader$.pipe(switchMap((x) => x.hasDocuments$));
|
|
2568
2577
|
this.allDocumentRefs$ = this.loader$.pipe(switchMap((x) => x.allDocumentRefs$));
|
|
2569
2578
|
this.allDocuments$ = this.loader$.pipe(switchMap((x) => x.allDocuments$));
|
|
2570
2579
|
this.allDocumentData$ = this.loader$.pipe(switchMap((x) => x.allDocumentData$));
|
|
@@ -2616,6 +2625,10 @@ class AbstractDbxFirebaseDocumentStore extends LockSetComponentStore {
|
|
|
2616
2625
|
}
|
|
2617
2626
|
return document;
|
|
2618
2627
|
}), distinctUntilChanged(), shareReplay(1));
|
|
2628
|
+
/**
|
|
2629
|
+
* Whether or not an id/ref/key has been input and currentDocument is not null.
|
|
2630
|
+
*/
|
|
2631
|
+
this.hasRef$ = this.currentDocument$.pipe(map((x) => x?.documentRef != null), distinctUntilChanged(), shareReplay(1));
|
|
2619
2632
|
this.document$ = this.currentDocument$.pipe(filterMaybe(), distinctUntilChanged(), shareReplay(1));
|
|
2620
2633
|
this.documentLoadingState$ = this.currentDocument$.pipe(map((x) => (x ? successResult(x) : beginLoading())), shareReplay(1));
|
|
2621
2634
|
this.id$ = this.document$.pipe(map((x) => x.id), shareReplay(1));
|
|
@@ -2647,6 +2660,17 @@ class AbstractDbxFirebaseDocumentStore extends LockSetComponentStore {
|
|
|
2647
2660
|
}
|
|
2648
2661
|
return result;
|
|
2649
2662
|
}), shareReplay(1));
|
|
2663
|
+
/**
|
|
2664
|
+
* Returns false while hasRef$ is false, and then returns exists$.
|
|
2665
|
+
*/
|
|
2666
|
+
this.currentExists$ = this.hasRef$.pipe(switchMap((hasRef) => {
|
|
2667
|
+
if (hasRef) {
|
|
2668
|
+
return this.exists$;
|
|
2669
|
+
}
|
|
2670
|
+
else {
|
|
2671
|
+
return of(false);
|
|
2672
|
+
}
|
|
2673
|
+
}), shareReplay(1));
|
|
2650
2674
|
this.exists$ = this.currentData$.pipe(map((x) => isMaybeSo(x)), shareReplay(1));
|
|
2651
2675
|
this.doesNotExist$ = this.exists$.pipe(map((x) => !x), shareReplay(1));
|
|
2652
2676
|
this.modelIdentity$ = this.document$.pipe(map((x) => x.modelIdentity), shareReplay(1));
|