MCPcopy
hub / github.com/angular/angularfire / loadedData

Function loadedData

src/compat/database/list/audit-trail.ts:21–38  ·  view source on GitHub ↗
(query: DatabaseQuery, scheduler?: SchedulerLike)

Source from the content-addressed store, hash-verified

19}
20
21function 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
40function waitForLoaded<T>(query: DatabaseQuery, action$: Observable<SnapshotAction<T>[]>, scheduler?: SchedulerLike) {
41 const loaded$ = loadedData<T>(query, scheduler);

Callers 1

waitForLoadedFunction · 0.85

Calls 2

fromRefFunction · 0.90
forEachMethod · 0.65

Tested by

no test coverage detected