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

219
Views
How to detach firebase Realtime listeners?

I'm using the firebase real-time database version 9, and I use this method to retrieve back data:

const refList= ref(
  db,
  `users/${uid}`
);
onValue(refList, (snapshot) => {
  let allData = snapshot.val() === null ? [] : snapshot.val()
});

So this is real-time communication therefore this ref has to use a listener. I checked their documentation, they say to use the off() method onto the ref without any code examples.

refList.off()

Will this remove the listener?

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

0

The onValue call now returns a function that (when called) removes the listener. So:

const unsubscribe = onValue(refList, (snapshot) => {
  let allData = snapshot.val() === null ? [] : snapshot.val()
});

And then later:

unsubscribe();
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!