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,483
  • 4
  • 16
  • 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
  • 85,731
  • 23
  • 174
  • 212