Sergio Crespo Toubes
02/26/2019, 11:10 AMval authToken = userManager.getStoredUser()?.authToken ?: return
GlobalScope.launch(Dispatchers.Main) {
withContext(Dispatchers.Default) {
val either = Try {
mBooksService.getBooksService(authToken).await()
}.toEither()
}
}
is this a clean async method api call? i am using Deferred adapter of Jake Wharton with retrofit.
Later i have a problem with binding
. This is the error: Restricted suspending functions can only invoke member or extension suspending functions on their restricted coroutine scope
with this code val authToken = userManager.getStoredUser()?.authToken ?: return
GlobalScope.launch(Dispatchers.Main) {
withContext(Dispatchers.Default) {
binding{
mBooksService.getBooksService(authToken).await()
}
val either = Try {
Try { mBooksService.getBooksService(authToken).await() }
}.toEither()
}
}
Any opinion of this code and error please? Thanks