Skip to content

Instantly share code, notes, and snippets.

@jorgecasariego
Created February 17, 2020 20:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jorgecasariego/cbf0b94e14e70b312742120319cebc20 to your computer and use it in GitHub Desktop.
Save jorgecasariego/cbf0b94e14e70b312742120319cebc20 to your computer and use it in GitHub Desktop.
// Dispatchers.Main
suspend fun fetchDocs() {
// Dispatchers.Main
val result = get("developer.android.com")
// Dispatchers.Main
show(result)
}
// Dispatchers.Main
suspend fun get(url: String) =
// Dispatchers.Main
withContext(Dispatchers.IO) {
// Dispatchers.IO
/* perform blocking network IO here */
}
// Dispatchers.Main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment