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

menegatti

03/31/2017, 10:53 AM
I was trying to keep coroutine related code away from the presenter, but let me try your thing
k

kingsley

03/31/2017, 10:59 AM
I don't think there is much you can do without introducing coroutine in the presentation layer. Since suspension can only happen within a coroutine context. Avoiding it means you either have to block somehow, or go back to the regular async+callback way
m

menegatti

03/31/2017, 11:00 AM
yeah, that's the same conclusion I arrived to
👍 1
when are you handling exceptions? when awaiting, I assume?
k

kingsley

03/31/2017, 11:21 AM
Yes. You can do that. It gets tricky though, because cancellation exceptions could also get thrown, which you shouldn't be handling. The framework knows how to deal with that. So, I wrap all results, both success and exception, and leave any other exceptions (ideally cancellation) for the framework to handle
You can checkout the retrofit coroutines library's
awaitResult
3 Views