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

114
Visualizações
Wait until multiple firestore onSnapshot finish workaround

Look, i have an app using live updates from Firestore for the authenticated user, the app settings and some locations.

My code looks like this:

 firestore
      .collection("settings")
      .doc("client")
      .onSnapshot(
        (doc) => {
          settingContext.setSetting(doc.data());
        }
      );

firestore
      .collection("users")
      .doc(user.uid)
      .onSnapshot(
        (doc) => {
            authContext.updateLoggedInUser({ id: user.uid, ...doc.data() });
        }
      );

But i also, request some other information to Firestore in the same function (initApp). The last request in this function lets the app know is ready to launch, but the problem here is that, at this point, is difficult to know if the three onSnapshots have returned data, and this data is needed to condition the screens in my app.

So i've been trying to create workarounds to make this work inline and what i mean by inline is to execute all request and get the data in the order i set them in the code.

I know this is quite hard, because the response of snapShots depends on various factors (internet speed for example).

I tried to wrap this calls inside a Promise(Just to be able to await them) and resolve once i receive data, but as you might guess, this will only return data once and i need to continue receiving live updates.

Any suggestions?

about 4 years ago · Juan Pablo Isaza
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