firebase-ios-sdk
firebase-ios-sdk copied to clipboard
[FR]: A promise that will initialize firebase (pause the code until firebase is working)
Description
-
Before your firebase code can run, firebase always needs a few moments until it can run.
-
Mostly used is OnAuthStateChanged() which executes the code when a user is found. However that does not work when there is no user or when the code that needs to know if there is a user starts immidiatly. So there is always a timing problem which can be hard to solve (To use a timer for example is not how you want the code to work)
-
To have a promise like await initFirebase() that will wait until firebase is ready to be used would be fantastic.
Thank you for your time
API Proposal
No response
Firebase Product(s)
Performance
I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.
Please provide more clarity about the request.
What specifically about FirebasePerformance needs this capability?
You mention OnAuthStateChanged(). What would you like to happen if there is no user logged in?
When you use OnAuthStateChanged, the first value that is returned is always null (because firebase is not yet initialized). So it would be generally nice to have a function/promise that you can run to make sure firebase is initialized before the code continues. Because if that would be the case, you can then just run const user = await auth.currentUser and then you would always know if a user is logged in (why I think that this would be better than just simply OnAuthStateChanged() is because the first value you get from OnAuthStateChanged() is always null no matter if the user is authenticated or not). My issue is not with a specific function, I just think that it would be easier to code with firebase when you could make sure that firebase is initialized and able to run and for that purpose OnAuthStateChanged is not ideal.
PS.: I am sorry when this sounds to complicated or when I am just missing something, if it helps I can send a .js file to make my point clearer
From: Paul Beusterien @.> Sent: Friday, August 23, 2024 3:46:37 PM To: firebase/firebase-ios-sdk @.> Cc: Sameszop @.>; Author @.> Subject: Re: [firebase/firebase-ios-sdk] [FR]: A promise that will initialize firebase (pause the code until firebase is working) (Issue #13533)
Please provide more clarity about the request.
What specifically about FirebasePerformance needs this capability?
You mention OnAuthStateChanged(). What would you like to happen if there is no user logged in?
— Reply to this email directly, view it on GitHubhttps://github.com/firebase/firebase-ios-sdk/issues/13533#issuecomment-2307133036, or unsubscribehttps://github.com/notifications/unsubscribe-auth/BE3AROXLIXAJD3RDEDLJC5DZS44L3AVCNFSM6AAAAABM7WEYSKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMBXGEZTGMBTGY. You are receiving this because you authored the thread.Message ID: @.***>
Thanks for the clarification. I understand the request. It's a feature request for FirebaseAuth, not FirebasePerformance.
See discussion at https://github.com/firebase/firebase-ios-sdk/issues/13231#issuecomment-2323424347