Hello! I try to start/launch a Kotlin Flow from Gr...
# flow
c
Hello! I try to start/launch a Kotlin Flow from Groovy/Spock. The Flow I want to test is created by a Kotlin function. This is what I roughly try to achieve:
Copy code
def results = []
BuildersKt.runBlocking(EmptyCoroutineContext.INSTANCE) {
    sut.createFlow(someArg).collect { results << it }
}
I have found this SO post but haven't discovered a simpler solution, yet. Can someone please help me out? Thanks!
Hello @elizarov, is there a way to start Kotlin Flows from non-Kotlin code (e.g. using Java/Groovy) and if so, how?
e
Yes, you can convert a flow to some Java-friendly reactive type that does not rely on coroutines. We do provide a bunch of converts (to Rx, to project Reactor, and to Java 9 flows).