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

230
Views
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 answers
Answer question

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 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!