javaspringreactive-programming

Spring Reactive List of Mono to Flux


I have a

list.stream()
.map(element -> func());

where func() returns with Mono. What is the easiest way to convert this list of Mono<CustomObject> objects to Flux<CustomObject> and return it from the stream?


Solution

  • List<Mono<CustomObject >> monoList = new ArrayList<>();
    monoList(object);
    
    Flux<CustomObject> flux = Flux.concat(monoList);