https://kotlinlang.org logo
#coroutines
Title
# coroutines
e

elizarov

03/04/2017, 3:18 PM
The key advantage of coroutines is that they let you avoid callback hell. For example, you can replace deeply nested flatmaps with a simple and easy-to-understand imperative-style "do this, do that" code. If you don't have any of that and all your Rx code is just "take this IO result, switch to UI thread, display it" or "take this button click, then do some IO", then you will not find much difference between Rx and coroutines.
a

adeln

03/04/2017, 3:22 PM
elizarov: thing is, coming from languages like haskell and scala, I try to use coroutines as some kind of sugar for flatmaps (say do notation or for comprehention)
e

elizarov

03/04/2017, 3:24 PM
That is a valid viewpoint. However, in imperative language like Kotlin you don't need any syntactic sugar for flatmaps, because you are not forced to use flatmaps to express sequential (imperative) excution in the first place.
4 Views