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

89
Views
Combine multiple requests and subscribe sequentially with rxjs

I have a loop that sends x http requests.

In some cases user can send a so many requests and that could affect server performances.

I would like to convert existing logic and be able ho manage max requests number.

Sample code

for( let i; i<x; i++ ) {
  this.subs= this.globalService.getData(formData, id).subscribe(data => {...}
}

How can I authorise triger only if the number of requests is < 10 for example otherwise wait for api response and check if current observers is less than 10 ?

It's important to subscribe sequentially and not send an array of data to not change code logic inside subscription.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Probably the easiest way is using mergeMap() with an optional concurrency option.

range(x)
  .pipe(
    mergeMap(i =>  this.globalService.getData(formData, i), 10),
  )
  .subscribe();

This way you can make mergeMap() to perform at most 10 concurrent requests.

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!