0

I was wondering the best way to achieve this.

If i have two observables A & B, and i want to process the next B logic after the A has completed his next logic.

I'm currently using combineLatest for that purpose.

Any best choice?

Thanks!

fercaveri
  • 63
  • 1
  • 11
  • Theres heaps of ways to do this and there is no 'best' way if how your doing it works, leave it at that. – Smokey Dawson Mar 18 '20 at 21:45
  • look at mergeMap operator, combineLatest is Promise.all but your order matters hence should not be using it – EugenSunic Mar 18 '20 at 21:55
  • Does this answer your question? [How Does RxJS MergeMap Work?](https://stackoverflow.com/questions/42120680/how-does-rxjs-mergemap-work) – EugenSunic Mar 18 '20 at 21:56
  • One thing to note with `combineLatest` is that there is no way to impose an order of execution. It is going to trigger regardless of whether **A** or **B** is pushed first. – ruth Mar 18 '20 at 22:46

1 Answers1

1

I would use b$.pipe(withLatestFrom(a$)). This way you can see things clearly. But combineLatest works fine.