You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
build: classify the firebase symbols a version raise would newly wrap (#3759)
The build regenerates src/<module>/firebase.ts from the declarations of whatever
firebase is installed, wrapping every lowercase-initial function. Raising the
minimum version would wrap symbols nobody has classified, and one breaks: the auth
persistence exports are classes that firebase constructs with `new`, and the
wrapper replaces them with an ordinary function. These entries settle that first
and stay inert until the version rises.
Do not wrap maximum, minimum, getTemplateGenerativeModel, makeMemoryCacheProvider
or browserCookiePersistence. Wrap the messaging subscriptions with blockUntilFirst
off, matching onMessage, since they fire on a registration change that may never
happen and would otherwise hold a pending task open indefinitely.
The generator is now exported so `npm run generate` runs it without `ng build`,
and it fails on an override key its entry point does not declare, which is
otherwise ignored in silence.
Also removes ngPostUpdate, an ng update migration that returned its Tree unchanged,
and adds a docs/zones.md section on what a call outside an injection context loses.
Refs #3756
Reach for `runInInjectionContext` only when the call genuinely must run inside the callback, as the per-user query above does (it needs the signed-in user's `uid`).
51
51
52
+
### Why the injection context is required
53
+
54
+
AngularFire cannot create an injection context, only borrow the one you are already in.
55
+
56
+
When you call a wrapped API, the first thing AngularFire does is ask Angular for three things with `inject()`: its own scheduler service, Angular's `PendingTasks` register, and an `EnvironmentInjector`. `inject()` only works inside an injection context, so outside of one the first of them throws and the rest are never reached. AngularFire catches that, warns while in dev-mode as described under Logging below, and calls the Firebase API directly with nothing added.
57
+
58
+
That division is worth knowing, because it explains what you are and are not responsible for:
59
+
60
+
***You** supply the context at the call site, from a field initializer, a constructor, or an explicit `runInInjectionContext`.
61
+
***AngularFire** re-enters the environment injector inside a callback you hand to the call itself, which is why you never wrap an `onSnapshot` handler yourself. That reaches anything provided at the application level, but not providers declared on a component, and it does not extend to subscribers of a returned Observable, which is what the `switchMap` and `runInInjectionContext` example above is for.
62
+
63
+
What you lose depends on the call. A call that does asynchronous work, such as `onSnapshot`, `getDoc` or `collectionData`, is normally added to Angular's `PendingTasks` register, which is what server-side rendering waits on before it serializes the page. Called outside a context, it never is. A call that returns immediately, such as `getFirestore`, was never registered anyway, so it loses only the zone handling.
64
+
52
65
## Logging
53
66
54
67
You may see a log warning, `Calling Firebase APIs outside of an Injection context may destabilize your application leading to subtle change-detection and hydration bugs. Find more at https://github.com/angular/angularfire/blob/main/docs/zones.md` when developing your application.
Copy file name to clipboardExpand all lines: src/schematics/migration.json
-5Lines changed: 0 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -10,11 +10,6 @@
10
10
"version": "21.0.0",
11
11
"description": "Align the workspace's firebase dependency with the range @angular/fire 21 requires, and rewrite Vertex AI imports to Firebase AI Logic (getVertexAI callers keep the Vertex AI backend)",
12
12
"factory": "./update/v21#ngUpdate"
13
-
},
14
-
"ng-post-upgate": {
15
-
"description": "Print out results after ng-update",
0 commit comments