There is no much difference between coroutines and...
# coroutines
e
There is no much difference between coroutines and promises for simple stuff. Compare:
Copy code
promise.then {
    it.doSomething() 
}
with
Copy code
launch {
    promise.await().doSomething() 
}
This is quite a liberal example hand-crafted so that both direct usage of promise and coroutines somewhat match in readability. Coroutine benefits accrue with complex processing pipelines (do something async, then something else async, handle exceptions of multiple async actions in one place, etc).
a
though there’s a difference if you have a chain of two or more and if you ditch promises and go all-in with
suspend
, it becomes much cleaner 🙂
e
Yes. It does become cleaner if you ditch promises completely.
a
wow, pretty cool!