I´m invoking from Kotlin a Scala class that return a Future, I can make an Await of that future
private fun scalaFutureInKotlin() {
val future: Future<String> = Future.successful("Hello world from Scala")
val result: String? = Await.result(future, Duration.apply(10, TimeUnit.SECONDS))
println(result)
}
But what I really want is to being able to implement the onComplete
callback and pass the value into a Kotlin Channel
or Flow
to being used in another coroutine
, so then I dont block any thread.
Any idea how to implement a onComplete
function of a Scala Future
in Kotlin
?