val service = createGitHubService(username, token) data class Status(val isLoading: Boolean, val data: List<Repo>?, val throwable: Throwable?) private val _status = MutableLiveData<Status>() val status: LiveData<Status> = _status init { load() } fun load() { _status.value = Status(true, null, null) service.reposOf("google").enqueue(object : Callback<List<Repo>> { override fun onResponse(call: Call<List<Repo>>, response: Response<List<Repo>>) { _status.value = if (response.isSuccessful) { Status(false, response.body()!!, null) } else { Status(false, null, IllegalStateException()) } } override fun onFailure(call: Call<List<Repo>>, t: Throwable) { _status.value = Status(false, null, t) } }) } }