1

I have a scenario where I have three http requests that must be executed in order, and after all three emitted a value, I must do a redirect.

I achieved this using concat

concat(request1$, request2$, request3$).subscribe(
   () => {},
   (err) => {},
   () => redirect...
)

But I would like to know if there is an operator that does this specifically (execute in order and emit only when all observables emit).

R. Richards
  • 24,603
  • 10
  • 64
  • 64
Marco Prado
  • 1,208
  • 1
  • 12
  • 23
  • https://stackoverflow.com/questions/51210629/angular-6-pipe-rxjs-operator-to-chain-3-dependant-observables – monstertjie_za Aug 01 '19 at 13:52
  • `concat` is the right way to go. If you would rather do your redirect in the `next` callback instead of the `complete` callback you could add `.pipe(toArray())` or `.pipe(last())` to your `concat` observable. You could also chain your requests with `concatMap` or `switchMap` but that wouldn't be more elegant. – frido Aug 01 '19 at 15:09
  • What do you expect the observable to emit here? An array, a single value or a sequence of values? We understand that you want the observables to complete in order, but please clarify the output. – Reactgular Aug 01 '19 at 15:24
  • Did you find a solution for this? – Dreadnaut Apr 20 '21 at 07:28

0 Answers0