Home > Software design >  Is possible to convert a Flux to Mono
Is possible to convert a Flux to Mono

Time:01-23

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

CodePudding user response:

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

  •  Tags:  
  • Related