Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create Flux from Mono

I have a Mono A. The Object A contains two lists. I want to create direct two Flux. Is this possible without block()?

Mono<A> a = ... ;

Flux<AList1> a1 =  Flux.fromIterable(a.block().getList1());
like image 316
trap Avatar asked Mar 09 '18 09:03

trap


1 Answers

Use Mono.flatMapMany() method:

    Flux flux1 = mono.map(A::getList1).flatMapMany(Flux::fromIterable);
    Flux flux2 = mono.map(A::getList2).flatMapMany(Flux::fromIterable);
like image 83
mroman Avatar answered Sep 29 '22 12:09

mroman