smallrye / smallrye-mutiny

An Intuitive Event-Driven Reactive Programming Library for Java
https://smallrye.io/smallrye-mutiny
Apache License 2.0
796 stars 125 forks source link

Confused about `Multi.asFlow` extension #1316

Open hantsy opened 1 year ago

hantsy commented 1 year ago

Kotlinx coroutines Reactive includes an general extension fun to convert Publisher to Kotlin Flow, https://github.com/Kotlin/kotlinx.coroutines/blob/master/reactive/kotlinx-coroutines-reactive/src/ReactiveFlow.kt

Besides add extensions to general ReactiveStreams API, https://github.com/Kotlin/kotlinx.coroutines/tree/master/reactive it also supports Reactor, Rxjava2/3, JDK 9 Flow API.

But in these implementations, it does requires a suspend modifier for fun .asFlow.

jponge commented 1 year ago

/cc @heubeck

heubeck commented 1 year ago

Thank you for pointing this out, @hantsy. Mutiny-Kotlin was created before Mutiny switched to the Publisher API.

Will have a look and probably propose a refactoring.

hantsy commented 1 year ago

The JDK9 extension also includes a asFlow fun, I have tried here https://github.com/hantsy/quarkus-sandbox/blob/master/mongodb-kotlin-co/src/main/kotlin/com/example/PostResources.kt#L4 and https://github.com/hantsy/quarkus-sandbox/blob/master/mongodb-kotlin-co/src/main/kotlin/com/example/PostResources.kt#L28 it works.

heubeck commented 1 year ago

lets follow up on this discussion in https://github.com/smallrye/smallrye-mutiny/issues/1325