简体   繁体   中英

Is possible to convert a Flux to Mono

I playing around with r2dc for spring boot java application.

I was thinking if possible to convert a Flux to Mono for certain calculation.

Pseudo example:

static PseudoMagic calculate(List<Foo> foos) {
   return callTheMagicRutine(foos)
}

Mono<PseudoMagic> getMyMagic() {
   Flux<Foo> foos = getMyFoos()
   foos.transformToMagic(f -> calculator(f))
}

You need to use collectList() method in Flux to transform the Flux<Foo> to Mono<List<Foo>> . That is the best you can do.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM