concatMap()
Just as there is flatMap(), which dynamically merges Observables derived off each emission, there is a concatenation counterpart called concatMap(). You should prefer this operator if you care about ordering and want each Observable mapped from each emission to finish before starting the next one. More specifically, concatMap() will merge each mapped Observable sequentially and fire it one at a time. It will only move to the next Observable when the current one calls onComplete(). If source emissions produce Observables faster than concatMap() can emit from them, those Observables will be queued.
Our earlier flatMap() examples would be better suited for concatMap() if we explicitly cared about emission order. Although our example ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access