Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
class MainPresenter(private val view: MainView,
private val dataProvider: DataProviderAPI
private val uiContext: CoroutineContext = UI,
private val ioContext: CoroutineContext = CommonPool) {
private fun loadData() = launch(uiContext) { // use the provided uiContext (UI)
view.showLoading()
// use the provided ioContext (CommonPool)
val task = async(bgContext) { 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