Last active
October 10, 2017 04:24
-
-
Save dmytrodanylyk/69352c7e97ea5e62edf2892576dee5a3 to your computer and use it in GitHub Desktop.
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
private fun loadData() = launch(uiContext) { | |
view.showLoading() // ui thread | |
val task1 = async(bgContext) { dataProvider.loadData("Task 1") } | |
val task2 = async(bgContext) { dataProvider.loadData("Task 2") } | |
val result = "${task1.await()} ${task2.await()}" // non ui thread, suspend until finished | |
view.showData(result) // ui thread | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment