Created
October 10, 2018 18:57
-
-
Save mayojava/448daa211bd8985f15ff6b025ba21a7a to your computer and use it in GitHub Desktop.
coroutine implementation of fetch user orders snippet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun showUserOrders(username: String, password: String) = GlobalScope.launch(Dispatchers.Main) { | |
val user = withContext(Dispatchers.Default) { login(username, password) } | |
val orders = withContext(Dispatchers.Default) { fetchUserOrders(user.userId) } | |
showUserOrders(orders) | |
} | |
suspend fun login(username: String, password: String) { } | |
suspend fun fetchUserOrders(userId: Long) { } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment