`runBlocking` is a bridge between the coroutine "w...
# coroutines
p
runBlocking
is a bridge between the coroutine "world" and normal non-coroutine "world". Are there any other "bridges"? I am looking for
runNonBlocking
.
b
You can also use JDK APIs like
CompletableFuture
via the
kotlinx-coroutines-jdk8
module
Copy code
val myFuture = future<Int> { 
    delay(100)
    100
}
Note: the coroutine APIs, including
launch
, spend a lot of time ensuring deep cancellation and handled failures. They’re definitely my go-to over futures.
p
hmm.. didn't know about this module.. will probably try to learn the native kotlin way since my project is 100% kotlin
d
async {}
is also another bridge when you need the result (or to bubble up an exception thrown, since launch will just "swallow" the exception...), just learn about structured concurrency before you start with them, so you don't leak your coroutines.