Ad

Is Possible To Convert A Flux To Mono

- 1 answer

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))
}
Ad

Answer

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

Ad
source: stackoverflow.com
Ad