docs(zones): show how to keep AngularFire calls in an injection context#3721
Open
armando-navarro wants to merge 1 commit into
Open
docs(zones): show how to keep AngularFire calls in an injection context#3721armando-navarro wants to merge 1 commit into
armando-navarro wants to merge 1 commit into
Conversation
The zone-wrappers guide explains what the "outside of an Injection context" warning means and how to change its log level, but never shows how to fix the code that triggers it. angular#3629 asks for exactly that. This adds a "Keeping calls inside an injection context" section covering the most common trigger: an AngularFire API called inside an async callback (for example a Firestore query built inside a switchMap on the signed-in user), where the callback runs after the synchronous injection context is gone. The recipe captures an EnvironmentInjector while the context is active and re-establishes it inside the callback with runInInjectionContext, plus a note to prefer hoisting the call out of the callback when it doesn't depend on the async value. Docs-only; no code or behavior change. Fixes angular#3629
tyler-reitz
approved these changes
Jul 21, 2026
tyler-reitz
left a comment
Collaborator
There was a problem hiding this comment.
Good addition. The two-example structure works well: hoist when you can, runInInjectionContext when you need the per-emission value. The EnvironmentInjector field pattern is the right way to bridge the sync/async boundary.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The zone-wrappers guide explains what the "outside of an Injection context" warning means and how to change its log level, but never shows how to fix the code that triggers it. #3629 asks for exactly that.
This adds a "Keeping calls inside an injection context" section covering the most common trigger: an AngularFire API called inside an async callback (for example a Firestore query built inside a
switchMapon the signed-in user), where the callback runs after the synchronous injection context is gone. The recipe captures anEnvironmentInjectorwhile the context is active and re-establishes it inside the callback withrunInInjectionContext, plus a note to prefer hoisting the call out of the callback when it doesn't depend on the async value.Docs-only; no code or behavior change.
Fixes #3629