Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

174
Views
Would it be okay to put onSnapshot() inside an onAuthStateChanged()?

I have one collection of users with some data in firestore (with their uid as the key). After login, first thing I want to do is show the user data and the user being able to modify it, but if onSnapshot execute outside onAuthStateChanged before I retrieve the user uid to get the doc ref, it will fail the first time which causes my code to stop executing. For some reason that error is not caught, so is it good practice to put it in onAuthStateChanged to make sure that I get the user uid before the first time onSnapshot is executed?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

If your onSnapshot listener depends on the current user, then it's idiomatic to attach that listener on an onAuthStateChanged handler when the user becomes not null, and subsequently detach it there when the user becomes null again.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!