Skip to content

Instantly share code, notes, and snippets.

@dmytrodanylyk
Last active October 10, 2017 04:25
Show Gist options
  • Save dmytrodanylyk/9750313d7546a11d7936f33f1c2cfb95 to your computer and use it in GitHub Desktop.
Save dmytrodanylyk/9750313d7546a11d7936f33f1c2cfb95 to your computer and use it in GitHub Desktop.
private fun loadData() = async(uiContext) {
view.showLoading() // ui thread
val task = async(bgContext) { dataProvider.loadData("Task") }
val result = task.await() // non ui thread, suspend until the task is finished
view.showData(result) // ui thread
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment