anthonyeef
08/30/2017, 8:18 AMasync(UI) {
val fetchDataJob = bg {
ColumnRepo.getFromRemote(22352581)
}
val data = fetchDataJob.await()
info(data.id.toString())
if (fetchDataJob.isCompletedExceptionally) {
doSomeThingWithException(fetchDataJob.getCompletionException())
}
}
gildor
08/30/2017, 8:58 AMgildor
08/30/2017, 9:00 AMasync(UI) {
try {
val data = fetchData(22352581)
//or something like
//val data = run(YourDispatcher) { ColumnRepo.getFromRemote(22352581) }
info(data.id.toString())
} catch(e: Exception) {
doSomeThingWithException(e)
}
}
anthonyeef
08/30/2017, 9:30 AMbg()
is from Anko. And you are right, that await()
make this single request more complecatedgildor
08/30/2017, 9:31 AM