https://kotlinlang.org logo
m

marcinmoskala

11/11/2017, 4:52 AM
Code I want to use:
Copy code
import com.jetbrains.kotlinconf.repositories.NewsRepository
import kotlinx.coroutines.experimental.async
import kotlinx.coroutines.experimental.launch

class QuestsPresenter(val view: QuestsView) {

    private val repository by NewsRepository.lazyGet()

    fun onCreate() {
        view.loading = true
        launch {
            try {
                val news = async { repository.getNews() }.await()
                view.loading = false
                view.showList(news)
            } catch (t: Throwable) {
                view.showError(t)
            }
        }
    }
}