Is there a good way to interop from `Mono / Flux` ...
# arrow
c
Is there a good way to interop from
Mono / Flux
to
Either / Validated
? I find the suspended handling of
parZip / parTraverse
to be much more intuitive than the Webflux functionalities
s
You could probably use (or build something on top of) this https://github.com/Kotlin/kotlinx.coroutines/tree/master/reactive
s
Are you looking for something like:
Copy code
suspen fun <A> Mono<A>.toEither(): Either<Throwable, A?> = 
  Either.catch {
    awaitSingleOrNull()
  }
For
Flux
you could do the same but with
collectList
or
take
etc since need to deal somehow with how many elements you'd want to collect from the
Flux
to have it completed correctly.
A better option might be if we add
parZip
to
Flow
and you could work with
Flux
/
Flow
iteropt so you can keep treating it as a stream without waiting until completion inside
suspend