firebase-js-sdk
firebase-js-sdk copied to clipboard
Issue #462 fix : Add new method that returns the logged-in user as Promise :
Issue https://github.com/firebase/firebase-js-sdk/issues/462 Hi, firebase team! I am sure this pull-request is far from complete since I lack an understanding of the codebase.
onAuthStateChanged
has the following caveats that seem to be making it difficult for new-comers to get started with firebase-auth
:
- The method name doesn't clearly indicate a very common use-case: getting the current user info. Also, the method name implies that some state has to be changed in order for the callback to be triggered, but the callback is also triggered when auth is not pending (no user is logged in).
- Callbacks have caveats when compared to promises, which can be chained and utilized with the
async
keyword.
I was asked to tag @avolkovi and @bojeil-google.
⚠️ No Changeset found
Latest commit: 6c56c980abd2f5dd5b512d59103092ad53b1fd56
Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.
This PR includes no changesets
When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types
Click here to learn what changesets are, and how to add one.
Click here if you're a maintainer who wants to add a changeset to this PR
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).
:memo: Please visit https://cla.developers.google.com/ to sign.
Once you've signed (or fixed any issues), please reply here with @googlebot I signed it!
and we'll verify it.
What to do if you already signed the CLA
Individual signers
- It's possible we don't have your GitHub username or you're using a different email address on your commit. Check your existing CLA data and verify that your email is set on your git commits.
Corporate signers
- Your company has a Point of Contact who decides which employees are authorized to participate. Ask your POC to be added to the group of authorized contributors. If you don't know who your Point of Contact is, direct the Google project maintainer to go/cla#troubleshoot (Public version).
- The email used to register you as an authorized contributor must be the email used for the Git commit. Check your existing CLA data and verify that your email is set on your git commits.
- The email used to register you as an authorized contributor must also be attached to your GitHub account.
ℹ️ Googlers: Go here for more info.
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).
:memo: Please visit https://cla.developers.google.com/ to sign.
Once you've signed (or fixed any issues), please reply here with @googlebot I signed it!
and we'll verify it.
What to do if you already signed the CLA
Individual signers
- It's possible we don't have your GitHub username or you're using a different email address on your commit. Check your existing CLA data and verify that your email is set on your git commits.
Corporate signers
- Your company has a Point of Contact who decides which employees are authorized to participate. Ask your POC to be added to the group of authorized contributors. If you don't know who your Point of Contact is, direct the Google project maintainer to go/cla#troubleshoot (Public version).
- The email used to register you as an authorized contributor must be the email used for the Git commit. Check your existing CLA data and verify that your email is set on your git commits.
- The email used to register you as an authorized contributor must also be attached to your GitHub account.
ℹ️ Googlers: Go here for more info.
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).
:memo: Please visit https://cla.developers.google.com/ to sign.
Once you've signed (or fixed any issues), please reply here with @googlebot I signed it!
and we'll verify it.
What to do if you already signed the CLA
Individual signers
- It's possible we don't have your GitHub username or you're using a different email address on your commit. Check your existing CLA data and verify that your email is set on your git commits.
Corporate signers
- Your company has a Point of Contact who decides which employees are authorized to participate. Ask your POC to be added to the group of authorized contributors. If you don't know who your Point of Contact is, direct the Google project maintainer to go/cla#troubleshoot (Public version).
- The email used to register you as an authorized contributor must be the email used for the Git commit. Check your existing CLA data and verify that your email is set on your git commits.
- The email used to register you as an authorized contributor must also be attached to your GitHub account.
ℹ️ Googlers: Go here for more info.
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).
:memo: Please visit https://cla.developers.google.com/ to sign.
Once you've signed (or fixed any issues), please reply here with @googlebot I signed it!
and we'll verify it.
What to do if you already signed the CLA
Individual signers
- It's possible we don't have your GitHub username or you're using a different email address on your commit. Check your existing CLA data and verify that your email is set on your git commits.
Corporate signers
- Your company has a Point of Contact who decides which employees are authorized to participate. Ask your POC to be added to the group of authorized contributors. If you don't know who your Point of Contact is, direct the Google project maintainer to go/cla#troubleshoot (Public version).
- The email used to register you as an authorized contributor must be the email used for the Git commit. Check your existing CLA data and verify that your email is set on your git commits.
- The email used to register you as an authorized contributor must also be attached to your GitHub account.
ℹ️ Googlers: Go here for more info.
Hi @harshshredding, thank you very much for this pull request! API changes of this nature go through an internal process for approval. I'm sponsoring this and will get back to you in a few weeks!
Hi @harshshredding, thanks so much for your patience. After an internal review, we've concluded that this function should not itself return a user object. Instead, the function should return a Promise<void>
that resolves when the auth state is ready and settled (i.e. when reading auth().currentUser
is valid).
That function should be called authStateReady()
and have the following signature:
interface Auth {
authStateReady(): Promise<void>;
}
The function could then be used like:
async function doStuff() {
await firebase.auth().authStateReady();
nowSafeToRead(firebase.auth().currentUser);
}
I believe your function in this PR can be easily updated to do the same thing but simply not resolve with any value.
@sam-gc I will update the PR very soon. Thanks a lot for the feedback.
wow
@harshshredding
https://github.com/firebase/firebase-js-sdk/pull/4288#event-8542325400
??? What happened?
Sorry guys, I don't have the bandwidth. @sam-gc can you assign this to someone else?
Sorry guys, I don't have the bandwidth. Sam can you assign this to someone else?
We got API review feedback to expose this slightly differently. We are working on it in https://github.com/firebase/firebase-js-sdk/pull/7384