Skip to main content

Higher-order observables: switchMap, mergeMap, concatMap, exhaustMap

Learn Higher-order observables: switchMap, mergeMap, concatMap, exhaustMap (Module 12 · RxJS, Angular) with worked examples, diagrams and interview questions. Free on JavaSchoolLab.

Streams that start other streams • A higher-order observable is an observable whose values are themselves observables, for example "for every search term, start an HTTP call". You rarely handle it by hand: the flattening operators switchMap, mergeMap, concatMap and exhaustMap subscribe to the inner observable and flatten the results. • They differ in how they treat a new outer value while an inner one is still running: switchMap : cancel the old, start the new (latest wins). mergeMap : run all at once (concurrent). concatMap : queue, one after another (order preserved). exhaustMap : ignore new...

More lessons in Module 12 · RxJS