The flatMap
function in rxjs
is used to flatten and merge a higher-order observable. It can be used to transform the values emitted by an observable, and then merge the resulting observables.
Here's an example usage of flatMap
:
index.tsx306 chars19 lines
In this code snippet, we start by creating an observable letters$
that emits a, b, and c. We then use the flatMap
operator to transform each of those letters into an observable that emits two values: the uppercase letter followed by either 1 or 2.
Finally, we use the subscribe
method to log each of the emitted values.
gistlibby LogSnag