Skip to content

Instantly share code, notes, and snippets.

@KhomDrake
Created March 7, 2022 02:30
Show Gist options
  • Save KhomDrake/53aa7c9932eb186b108dffa14e43c2e3 to your computer and use it in GitHub Desktop.
Save KhomDrake/53aa7c9932eb186b108dffa14e43c2e3 to your computer and use it in GitHub Desktop.
fun loadMovies() {
backgroundScope.launch {
val movies = loadMovies() // load the movies on the background thread
launch(Dispatchers.Main) { // to touch the views to show the movies, we need to launch another coroutine in the main thread
showMovies(movies)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment