Useful Higher-Order Mapping Operators
Learn about some useful higher-order mapping operators.
We'll cover the following...
All higher-order mapping operators map each value from an outer observable to a new inner observable and automatically subscribe and unsubscribe from that inner observable. However, not all operators adopt the concat strategy. There are different strategies, such as merge, switch, and exhaust. Let’s break down those strategies!
The mergeMap
operator
The mergeMap
operator is the combination of the merge and transformation (or mapping) strategies:
mergeMap = merge(merge) + map (higher-order mapping)
Now that we understand well the concepts of higher-order mapping, let’s look at this marble diagram to understand the merging strategy. We’ll take the example of the merge
operator.
Unlike concat
, merge
won’t wait for an observable to complete before subscribing to the next observable. It subscribes to every inner observable at the same time and then outputs the values to the combined result. As described in this marble ...