-
Notifications
You must be signed in to change notification settings - Fork 308
add options to useAuthState hook "onUserChanged" #139
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
Conversation
Add possibility to pass options for onUserLoaded, a function which is called if a user auth state changed. This might close CSFrequency#33
// onUserLoaded function to process custom claims on any other trigger function | ||
await options.onUserChanged(user) | ||
} | ||
setValue(user); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will never be executed if the passed handler fails. It should be considered to set the value first and then perform the handler.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mauriceackel or should it be wrapped in try .. catch ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alternatively it could be mentioned that the onUserChanged
should handle errors within that function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This definitely needs some error handling built in, otherwise it will be very difficult to debug any issues. I'd propose a try / catch, then re-using setError
Thanks @dohomi and apologies for the slow review of the PR. I think this is an interesting way of solving the problem and can't decide if this or a |
@chrisbianca I added a try catch block inside of the function. I followed the documentation of Firebase thats why I added the option into the result of the |
Add possibility to pass options for onUserChanged, a function which is called if a user auth state changed.
This might close #33