@dereekb/dbx-firebase 8.4.0 → 8.5.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.
@@ -0,0 +1,52 @@
1
+ import { FirestoreDocument, IterationQueryDocChangeWatcherEvent } from '@dereekb/firebase';
2
+ import { Destroyable } from '@dereekb/util';
3
+ import { Observable } from 'rxjs';
4
+ import { DbxFirebaseCollectionStore } from '../store/store.collection';
5
+ /**
6
+ * DbxFirebaseCollectionChangeWatcher trigger modes
7
+ * - auto: will automatically call trigger
8
+ * - off: will never call trigger
9
+ */
10
+ export declare type DbxFirebaseCollectionChangeWatcherTriggerMode = 'auto' | 'off';
11
+ export declare type DbxFirebaseCollectionChangeWatcherEvent = Pick<IterationQueryDocChangeWatcherEvent<unknown>, 'time' | 'type'>;
12
+ /**
13
+ * Used to watch a DbxFirebaseCollectionStore for when the query changes and
14
+ */
15
+ export interface DbxFirebaseCollectionChangeWatcher {
16
+ /**
17
+ * Current mode
18
+ */
19
+ readonly mode$: Observable<DbxFirebaseCollectionChangeWatcherTriggerMode>;
20
+ /**
21
+ * Stream of events
22
+ */
23
+ readonly event$: Observable<DbxFirebaseCollectionChangeWatcherEvent>;
24
+ readonly hasChangeAvailable$: Observable<boolean>;
25
+ /**
26
+ * Current trigger state. Based on the hasChangeAvailable$ state and current mode.
27
+ */
28
+ readonly triggered$: Observable<boolean>;
29
+ /**
30
+ * Trigger emitter. Only emits when triggered$ is/becomes true.
31
+ */
32
+ readonly trigger$: Observable<void>;
33
+ mode: DbxFirebaseCollectionChangeWatcherTriggerMode;
34
+ }
35
+ /**
36
+ * DbxFirebaseCollectionChangeWatcher instance
37
+ */
38
+ export declare class DbxFirebaseCollectionChangeWatcherInstance<T = unknown, D extends FirestoreDocument<T> = FirestoreDocument<T>, S extends DbxFirebaseCollectionStore<T, D> = DbxFirebaseCollectionStore<T, D>> implements Destroyable {
39
+ readonly store: S;
40
+ private _mode;
41
+ private _sub;
42
+ readonly mode$: Observable<DbxFirebaseCollectionChangeWatcherTriggerMode>;
43
+ readonly event$: Observable<DbxFirebaseCollectionChangeWatcherEvent>;
44
+ readonly hasChangeAvailable$: Observable<boolean>;
45
+ readonly triggered$: Observable<boolean>;
46
+ readonly trigger$: Observable<void>;
47
+ constructor(store: S);
48
+ destroy(): void;
49
+ get mode(): DbxFirebaseCollectionChangeWatcherTriggerMode;
50
+ set mode(mode: DbxFirebaseCollectionChangeWatcherTriggerMode);
51
+ }
52
+ export declare function dbxFirebaseCollectionChangeWatcher<T = unknown, D extends FirestoreDocument<T> = FirestoreDocument<T>, S extends DbxFirebaseCollectionStore<T, D> = DbxFirebaseCollectionStore<T, D>>(store: S): DbxFirebaseCollectionChangeWatcherInstance<T, D, S>;
@@ -30,10 +30,22 @@ export interface DbxLimitedFirebaseDocumentLoader<T = unknown, D extends Firesto
30
30
  * Data from the documents.
31
31
  */
32
32
  readonly data$: Observable<DocumentDataWithId<T>[]>;
33
+ /**
34
+ * Snapshot stream of the documents
35
+ */
36
+ readonly snapshotsStream$: Observable<DocumentSnapshot<T>[]>;
37
+ /**
38
+ * Data stream of the documents.
39
+ */
40
+ readonly dataStream$: Observable<DocumentDataWithId<T>[]>;
33
41
  /**
34
42
  * Loading state for the document data.
35
43
  */
36
44
  readonly pageLoadingState$: Observable<PageListLoadingState<DocumentDataWithId<T>>>;
45
+ /**
46
+ * Loading state for the streamed document data.
47
+ */
48
+ readonly pageLoadingStateStream$: Observable<PageListLoadingState<DocumentDataWithId<T>>>;
37
49
  /**
38
50
  * Sets the keys of the models to load.
39
51
  *
@@ -21,7 +21,16 @@ export declare class DbxLimitedFirebaseDocumentLoaderInstance<T = unknown, D ext
21
21
  readonly refs$: Observable<DocumentReference<unknown>[]>;
22
22
  readonly snapshots$: Observable<DocumentSnapshot<T>[]>;
23
23
  readonly data$: Observable<DocumentDataWithId<T>[]>;
24
+ /**
25
+ * Snapshot stream of the documents
26
+ */
27
+ readonly snapshotsStream$: Observable<DocumentSnapshot<T>[]>;
28
+ /**
29
+ * Data streamd of the documents.
30
+ */
31
+ readonly dataStream$: Observable<DocumentDataWithId<T>[]>;
24
32
  readonly pageLoadingState$: Observable<PageListLoadingState<DocumentDataWithId<T>>>;
33
+ readonly pageLoadingStateStream$: Observable<PageListLoadingState<DocumentDataWithId<T>>>;
25
34
  constructor(_initConfig: DbxFirebaseDocumentLoaderInstanceInitConfig<T, D, A>);
26
35
  destroy(): void;
27
36
  restart(): void;
@@ -1,3 +1,4 @@
1
+ export * from './collection.change.watcher';
1
2
  export * from './collection.loader.instance';
2
3
  export * from './collection.loader';
3
4
  export * from './document.loader.instance';
@@ -1,30 +1,28 @@
1
- import { Observable } from 'rxjs';
2
1
  import { OnDestroy, OnInit } from '@angular/core';
3
- import { FirestoreDocument, IterationQueryDocChangeWatcherEvent } from '@dereekb/firebase';
2
+ import { FirestoreDocument } from '@dereekb/firebase';
4
3
  import { Maybe } from '@dereekb/util';
5
4
  import { DbxFirebaseCollectionStore } from './store.collection';
6
5
  import { DbxFirebaseCollectionStoreDirective } from './store.collection.directive';
7
6
  import { AbstractSubscriptionDirective } from '@dereekb/dbx-core';
7
+ import { DbxFirebaseCollectionChangeWatcher, DbxFirebaseCollectionChangeWatcherEvent, DbxFirebaseCollectionChangeWatcherTriggerMode } from '../loader/collection.change.watcher';
8
+ import { Observable } from 'rxjs';
8
9
  import * as i0 from "@angular/core";
9
- /**
10
- * Refresh mode
11
- */
12
- export declare type DbxFirebaseCollectionChangeDirectiveMode = 'auto' | 'manual';
13
- export declare type DbxFirebaseCollectionChangeDirectiveEvent = Pick<IterationQueryDocChangeWatcherEvent<unknown>, 'time' | 'type'>;
14
10
  /**
15
11
  * Used to watch query doc changes and respond to them accordingly.
16
12
  */
17
- export declare class DbxFirebaseCollectionChangeDirective<T = unknown, D extends FirestoreDocument<T> = FirestoreDocument<T>, S extends DbxFirebaseCollectionStore<T, D> = DbxFirebaseCollectionStore<T, D>> extends AbstractSubscriptionDirective implements OnInit, OnDestroy {
13
+ export declare class DbxFirebaseCollectionChangeDirective<T = unknown, D extends FirestoreDocument<T> = FirestoreDocument<T>, S extends DbxFirebaseCollectionStore<T, D> = DbxFirebaseCollectionStore<T, D>> extends AbstractSubscriptionDirective implements DbxFirebaseCollectionChangeWatcher, OnInit, OnDestroy {
18
14
  readonly dbxFirebaseCollectionStoreDirective: DbxFirebaseCollectionStoreDirective<T, D, S>;
19
- private _mode;
20
- readonly mode$: Observable<DbxFirebaseCollectionChangeDirectiveMode>;
21
- readonly event$: Observable<DbxFirebaseCollectionChangeDirectiveEvent>;
15
+ private _watcher;
16
+ readonly mode$: Observable<DbxFirebaseCollectionChangeWatcherTriggerMode>;
17
+ readonly event$: Observable<DbxFirebaseCollectionChangeWatcherEvent>;
22
18
  readonly hasChangeAvailable$: Observable<boolean>;
19
+ readonly triggered$: Observable<boolean>;
20
+ readonly trigger$: Observable<void>;
23
21
  constructor(dbxFirebaseCollectionStoreDirective: DbxFirebaseCollectionStoreDirective<T, D, S>);
24
22
  ngOnInit(): void;
25
23
  ngOnDestroy(): void;
26
- get mode(): DbxFirebaseCollectionChangeDirectiveMode;
27
- set mode(mode: Maybe<DbxFirebaseCollectionChangeDirectiveMode | ''>);
24
+ get mode(): DbxFirebaseCollectionChangeWatcherTriggerMode;
25
+ set mode(mode: Maybe<DbxFirebaseCollectionChangeWatcherTriggerMode | ''>);
28
26
  restart(): void;
29
27
  static ɵfac: i0.ɵɵFactoryDeclaration<DbxFirebaseCollectionChangeDirective<any, any, any>, never>;
30
28
  static ɵdir: i0.ɵɵDirectiveDeclaration<DbxFirebaseCollectionChangeDirective<any, any, any>, "[dbxFirebaseCollectionChange]", never, { "mode": "dbxFirebaseCollectionChange"; }, {}, never>;
package/package.json CHANGED
@@ -1,18 +1,18 @@
1
1
  {
2
2
  "name": "@dereekb/dbx-firebase",
3
- "version": "8.4.0",
3
+ "version": "8.5.2",
4
4
  "peerDependencies": {
5
5
  "@angular/common": "^13.0.0",
6
6
  "@angular/core": "^13.0.0",
7
- "@dereekb/util": "8.4.0",
7
+ "@dereekb/util": "8.5.2",
8
8
  "firebase": "^9.8.0",
9
9
  "rxjs": "^7.0.0",
10
10
  "@angular/fire": "^7.4.1",
11
- "@dereekb/firebase": "8.4.0",
12
- "@dereekb/dbx-core": "8.4.0",
11
+ "@dereekb/firebase": "8.5.2",
12
+ "@dereekb/dbx-core": "8.5.2",
13
13
  "@angular/material": "^13.0.0",
14
- "@dereekb/dbx-web": "8.4.0",
15
- "@dereekb/dbx-form": "8.4.0"
14
+ "@dereekb/dbx-web": "8.5.2",
15
+ "@dereekb/dbx-form": "8.5.2"
16
16
  },
17
17
  "dependencies": {
18
18
  "tslib": "^2.3.0"