How to convert Mono> into Flux

I’m converting small project written in RxJava 1.x to Reactor 3.x. All is good, except that I could not find out how to replace flatMap(Observable::from) with an appropriate counterpart. I have Mono<List<String>> and I need to convert it to Flux<String>.

Answer

In Reactor 3, the from operator has been specialized into a few variants, depending on the original source (array, iterable, etc…).

Use yourMono.flatMapMany(Flux::fromIterable) in your case.

Leave a Reply

Your email address will not be published. Required fields are marked *