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

229
Visualizações
Call firebase httpsCallable multiple times

Calling foo two times creates two subscribers and that is not ok but even so the second call of foo seems to get stuck somewhere because console.log gets called only one time. I know that I should not subscribe in this manner but I really do not see the solution to get myFunc to output the second result

const myFunc = functions.httpsCallable('myFunc')

function foo(inData){
  myFunc({data:inData}).subscribe((res)=>{
    console.log(res)
  })
}

foo('aaaaa')
foo('bbbbb')

second attempt still no luck

myFunc(data){
  return functions.httpsCallable('myFunc')(data)
}
async function foo(inData){
  let res = await lastValueFrom(myFunc({data:inData}))
  console.log(res)
}


foo('aaaaa')
foo('bbbbb')
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

The HttpsCallable function returns a promise by default. As you can see in this related question , there are a few differences between promises and observables, as it seems that you are already working with observables, I would try to convert the promise received from the function to an observable using this method, as suggested in this other question:

import { from } from 'rxjs';
const observable = from(promise);

Although, there are other methods suggested as well in the same question.

I would also like to point you to the Using observables to pass values, I think you might not have shared how you are creating the observer. I'm just guessing but you should also unsubscribe to clean up data ready for the next subscription. Also, missing next notification that is required. As an extra, I would say that if you are not obligated to use observables, handle it as a promise.

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