-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Firebase APIs outside of an Injection context #3607
Comments
This issue does not seem to follow the issue template. Make sure you provide all the required information. |
I am getting the same error: Line 82 in bc926a8
|
Just read #3590 (comment) |
Resolved using this #3590 (comment) |
not a solution |
No it is not. Just a workaround for now. |
I implemented this workaround as a static function in a helper class called OGSWAngularFirestoreHelper This worked for me for async calls:
But this will not work for standard sync calls like this because the work around is async:
So I created a sync version in my helper class:
BTW, here is my class constructor:
This is muddying up my logging. Any expected time for resolution? |
I have come to the conclusion that this warning is not helpful and so I have used the documentation to silence the warnings. import { LogLevel, setLogLevel } from '@angular/fire';
setLogLevel(LogLevel.SILENT); The problem is finding a place to do so now that Angular doesn't expose a |
A lot of people suggest this workaround |
@rgant so those warnings are something like "false positives" and can be fully ignored? |
The team is one developer working part time, and possibly not even really on the Angular side of things. But he is a good developer and knows that the Angular injection context is important. So he wanted to give us warnings, but applied the warnings in a global way when it probably should be more specific. There are probably cases where the context matters; James has mentioned experiencing problems. I haven't found any actual documentation on those specific experiences so I cannot really evaluate that. But I can comment on my code and it is working across a number of Firebase Authentication methods and with Firebase Storage and Firestore. Since I plan to test all of those cases, I don't feel that the warning is helpful to my case. If you aren't automated testing your code, then you might appreciate the reminders to consider the context of the methods. |
I've never said that people on the angular team were incompetent :) |
@adamstret I was attempting to explain that this is a part-time-single-developer project. It is not fully supported by the whole Angular team; it is not fully supported by the whole Firebase team. It is one good developer working to connect Angular and Firebase for us. So we cannot expect robust support like core Angular or Firebase products. If you look at the commit history you will see that there is primarily one developer working on this project, with some support from the user community. When James has time, generally around major releases, we get some updates. But outside of those times we are generally working with what we have. |
Oh I see, |
I keep getting error about,
Calling Firebase APIs outside of an Injection context may destabilize your application leading to subtle change-detection and hydration bugs.
I did properly set up the angular firebase integration although signIn, logIn working properly, but this error won't resolve and it makes the authentication delay at each reload.
Appconfig.ts -
const firebaseConfig = {
apiKey: "",
authDomain: "",
projectId: "",
storageBucket: "",
messagingSenderId: "",
appId: ""
}
export const appConfig: ApplicationConfig = {
providers:
[
provideZoneChangeDetection({ eventCoalescing: true }),
provideRouter(routes),
provideHttpClient(),
provideFirebaseApp(() => initializeApp(firebaseConfig)),
provideAuth(() => getAuth()),
provideFirestore(() => getFirestore())
]
};
Service:
auth: Auth = inject(Auth)
fireStore: Firestore = inject(Firestore)
ngZone = inject(NgZone)
userSubject: BehaviorSubject = new BehaviorSubject(null)
private authSubscription;
constructor() {
this.authSubscription = this.auth.onAuthStateChanged(user => {
this.userSubject.next(user)
})
}
signUp(fullName: string, email: string, password: string, username: string, phone: string = '', address: string = '', pincode: string): Observable {
return this.ngZone.run(() => {
}
saveUserDetails(uid: string, fullName: string, address: string, phone: string, pincode: string): Promise {
const userRef = doc(this.fireStore, 'users', uid)
}
Component:
onSubmit() {
const rawForm = this.signUpForm.getRawValue();
}
The text was updated successfully, but these errors were encountered: