Description
This is related to #3605 and #3607 where a workaround has been suggested #3590 (comment).
But my question is specifically for non-async functions.
First of all, thank you @jamesdaniels for the new guide at https://github.com/angular/angularfire/blob/main/docs/zones.md.
(I think the doc would benefit from some concrete examples.)
My understanding is that direct calls to docData where it's called say from within an rxjs switchMap, should be wrapped in runInInjectionContext
loadDoc<T>(docPath: string): Observable<T | undefined> {
return docData<T>(doc(this.firestore, docPath));
}
↓↓↓
private injectionContext = inject(EnvironmentInjector);
loadDoc<T>(docPath: string): Observable<T | undefined> {
return runInInjectionContext(this.injectionContext, () => {
return docData<T>(doc(this.firestore, docPath));
});
}
However, even after adding runInInjectionContext
wrappers for all load & set operations, there are still warnings from functions that are not async in nature such as where, snapToData, serverTimestamp, increment, orderBy, limit
:
This is because tools/build.ts
is applying ɵzoneWrap
to every Firebase function:
angularfire/src/firestore/rxfire.ts
Lines 22 to 27 in 8ce95bf
angularfire/src/firestore/firebase.ts
Lines 76 to 144 in 8ce95bf
Should AngularFire take a more granular approach and throw warnings only on async functions such as docData
to avoid extraneous warnings?