Today I finally stumbled upon the solution of a really trivial RX problem: Suppose you have an Observable which returns Lists of items. Like
Observable<List<String>>
. You often receive something like this as responses from web APIs.
However chances are you want to operate on the single items, in this case the Strings.
flatMapIterable
to the rescue! This handy operator flattens a stream ofIterables
into a stream generated from the single items of theseIterables
by means of a mapping function.
RxJava: flattening a stream of Iterables | by Sven Bendel
I'm writing in .NET Core if that matters.
Example in RxJava: Convert Observable<List<Car>>
to a sequence of Observable<Car>
in RxJava