Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit8ce95bf

Browse files
authored
Zone docs and switch to warnings (#3608)
* Warn rather than error, thats trippin folk* Add doc on zone wrappers* Words
1 parente567618 commit8ce95bf

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

‎docs/zones.md‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<small>
2+
<ahref="https://github.com/angular/angularfire">AngularFire</a>&#10097; <ahref="../README.md#developer-guide">Developer Guide</a>&#10097; Zone Wrappers
3+
</small>
4+
5+
#Zone Wrappers
6+
7+
AngularFire wraps the[framework agnostic Firebase JS SDK](https://github.com/firebase/firebase-js-sdk) and[RxFire](https://github.com/firebaseextended/rxfire) to ensure proper functionality in Zone and Zoneless applications alike.
8+
9+
These wrappers ensure Firebase APIs are called outside of the Angular zone. This isolates side-effects such as timers so that they do not destabilize your application.
10+
11+
Observables, Promise-based APIs, and those with callbacks will purposely destabilize your application until a initial value is returned, this ensures that server-side rendering (SSR) and static site generation (SSG/pre-rendering) wait for data before rendering the page's HTML.
12+
13+
##Consequences of not Zone wrapping
14+
15+
When using a Firebase or RxFire API without importing from AngularFire or if AngularFire APIs are used outside of an injection context you_may_ experience instability.
16+
17+
instability can be difficult to track down ([see Resolving zone pollution in the Angular docs](https://angular.dev/best-practices/zone-pollution)). To help with debugging, AngularFire emits warnings when it is unable to Zone wrap an API while in dev-mode.**Often these messages can be safely ignored** but we'd rather be verbose.
18+
19+
When an application is unstable change-detection, two-way binding, and rehydration may not work as expected—leading to both subtle and non-subtle bugs in your application. Further, server-side rendering (SSR) and static site generation (SSG/pre-rendering) may timeout or render a blank page.
20+
21+
There are a number of situations where AngularFire's Zone wrapping is inconsequential such adding/deleting/updating a document in response to user-input, signing a user in, calling a Cloud Function, etc. So long as no long-lived side-effects are kicked off, your application should be ok. Most Promise based APIs are fairly safe without zone wrapping.

‎src/zones.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,11 @@ function getSchedulers() {
8181
varalreadyWarned=false;
8282
functionwarnOutsideInjectionContext(original:any,operation:string){
8383
if(isDevMode()){
84-
console.warn(`Firebase API called outside injection context:${operation}(${original.name})`);
8584
if(!alreadyWarned){
8685
alreadyWarned=true;
87-
console.error("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");
86+
console.warn("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");
8887
}
88+
console.warn(`Firebase API called outside injection context:${operation}(${original.name})`);
8989
}
9090
}
9191

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp