Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

223
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda