(ref: DocumentReference<T>, scheduler?: SchedulerLike)
| 26 | } |
| 27 | |
| 28 | export 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 | |
| 46 | export 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' }))); |
no test coverage detected