Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

228
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda