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

AngularFireAuth's currentUser in ngOnInit #2733

Answered by mattbodman
zgosalvez asked this question in Q&A
Discussion options

On an older version, I could easily get the currentUser synchronously inside ngOnInit(). This is very useful when I need the currentUser.uid of the currently logged in user. However, after upgrading, currentUser now returns a promise instead, breaking my ngOnInit() and subcomponent. What's the best/easiest way to refactor my code to make this work again?

You must be logged in to vote

As far as I can tell, you can add async in front of your ngOnInit() function. Otherwise, you could do auth.currentUser.then(...)

Replies: 1 comment 1 reply

Comment options

As far as I can tell, you can add async in front of your ngOnInit() function. Otherwise, you could do auth.currentUser.then(...)

You must be logged in to vote
1 reply
Comment options

Decided on this route as well. Forgot to update this post. So far I haven't had any problems with this implementation.

Answer selected by zgosalvez
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /