https://kotlinlang.org logo
#android
Title
# android
v

victoralissont5

06/25/2019, 11:11 PM
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

gildor

06/26/2019, 12:40 AM
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