Created
October 9, 2017 05:00
-
-
Save dmytrodanylyk/903275c281617dd2b1807cca37953b67 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
class MainPresenter(private val view: MainView, | |
private val dataProvider: DataProviderAPI) { | |
private fun loadData() = launch(UI) { // UI - dispatches execution onto Android main UI thread | |
view.showLoading() | |
// CommonPool - represents common pool of shared threads as coroutine dispatcher | |
val task = async(CommonPool) { dataProvider.loadData("Task") } | |
val result = task.await() | |
view.showData(result) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment