Skip to content

Instantly share code, notes, and snippets.

@chaxiu
Created October 18, 2020 12:04
Show Gist options
  • Save chaxiu/6ce470e8100511dca57ddedf6c985b66 to your computer and use it in GitHub Desktop.
Save chaxiu/6ce470e8100511dca57ddedf6c985b66 to your computer and use it in GitHub Desktop.
// delay(1000L) representing request to server
//Suspending Function
// ↓
suspend fun getUserInfo(): String {
withContext(Dispatchers.IO) {
delay(1000L)
}
return "BoyCoder"
}
//Suspending Function
// ↓
suspend fun getFriendList(user: String): String {
withContext(Dispatchers.IO) {
delay(1000L)
}
return "Tom, Jack"
}
//Suspending Function
// ↓
suspend fun getFeedList(list: String): String {
withContext(Dispatchers.IO) {
delay(1000L)
}
return "{FeedList..}"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment