0
const source = Rx.Observable.from([1, 2, 3, 4, 5]);
const example = source.map(val => { /* asynchronous logic here*/ })
                      .map(val => { /* asynchronous logic here*/ });
                      .map(val => { /* asynchronous logic here*/ });

How to make so that each map waits for the asynchrounous execution of the previous map ?

user2080105
  • 1,642
  • 4
  • 18
  • 27

1 Answers1

2

You should use concatMap instead of map and return Observable from its callback:

const source = Rx.Observable.from([1, 2, 3, 4, 5]);
const example = source
  .concatMap(val => { /* asynchronous logic here*/ })
  .concatMap(val => { /* asynchronous logic here*/ })
  .concatMap(val => { /* asynchronous logic here*/ });
martin
  • 93,354
  • 25
  • 191
  • 226