Moreover, Kotlin's concept of suspending function ...
# android
v
Moreover, Kotlin's concept of suspending function provides a safer and less error-prone abstraction for asynchronous operations than futures and promises. Could someone explain why this is true?
g
Because suspend functions are sequential by nature, so it easier to write sequential asyncronous code , there is no way to forget start it as with future/promise, you invoke suspend function and suspend until value is returned, no need to support cancellation or lifecycle explicitly, suspend function always support it
2
Also it's covered in this exact guide from your link above: https://kotlinlang.org/docs/reference/coroutines/composing-suspending-functions.html
Also, a side note, please, do not cross post your messages to different channels, just find the most related one, and in this case it is #coroutines
3