MCPcopy Index your code
hub / github.com/angular/angularfire / fromDocRef

Function fromDocRef

src/compat/firestore/observable/fromRef.ts:28–44  ·  view source on GitHub ↗
(ref: DocumentReference<T>, scheduler?: SchedulerLike)

Source from the content-addressed store, hash-verified

26}
27
28export function fromDocRef<T>(ref: DocumentReference<T>, scheduler?: SchedulerLike): Observable<Action<DocumentSnapshot<T>>> {
29 return fromRef<DocumentSnapshot<T>, T>(ref, scheduler)
30 .pipe(
31 startWith<DocumentSnapshot<T>, undefined>(undefined),
32 pairwise(),
33 map((snapshots: [DocumentSnapshot<T>, DocumentSnapshot<T>]) => {
34 const [priorPayload, payload] = snapshots;
35 if (!payload.exists) {
36 return { payload, type: 'removed' };
37 }
38 if (!priorPayload?.exists) {
39 return { payload, type: 'added' };
40 }
41 return { payload, type: 'modified' };
42 })
43 );
44}
45
46export function fromCollectionRef<T>(ref: Query<T>, scheduler?: SchedulerLike): Observable<Action<QuerySnapshot<T>>> {
47 return fromRef<QuerySnapshot<T>, T>(ref, scheduler).pipe(map(payload => ({ payload, type: 'query' })));

Callers 1

snapshotChangesMethod · 0.90

Calls 1

fromRefFunction · 0.70

Tested by

no test coverage detected