(query: DatabaseQuery, scheduler?: SchedulerLike)
| 19 | } |
| 20 | |
| 21 | function loadedData<T>(query: DatabaseQuery, scheduler?: SchedulerLike): Observable<LoadedMetadata> { |
| 22 | // Create an observable of loaded values to retrieve the |
| 23 | // known dataset. This will allow us to know what key to |
| 24 | // emit the "whole" array at when listening for child events. |
| 25 | return fromRef<T>(query, 'value', 'on', scheduler) |
| 26 | .pipe( |
| 27 | map(data => { |
| 28 | // Store the last key in the data set |
| 29 | let lastKeyToLoad; |
| 30 | // Loop through loaded dataset to find the last key |
| 31 | data.payload.forEach(child => { |
| 32 | lastKeyToLoad = child.key; return false; |
| 33 | }); |
| 34 | // return data set and the current last key loaded |
| 35 | return { data, lastKeyToLoad }; |
| 36 | }) |
| 37 | ); |
| 38 | } |
| 39 | |
| 40 | function waitForLoaded<T>(query: DatabaseQuery, action$: Observable<SnapshotAction<T>[]>, scheduler?: SchedulerLike) { |
| 41 | const loaded$ = loadedData<T>(query, scheduler); |
no test coverage detected