Skip to content

Instantly share code, notes, and snippets.

@lnicolet lnicolet/MVIViewModel.kt
Last active May 29, 2019

Embed
What would you like to do?
class MVIViewModel : ViewModel() {
val viewState: MutableLiveData<MVIViewState>()
fun fetchData() {
myDataSource.fetchData()
.doOnSubscribe {
viewState.postValue(MVIViewState.Loading)
}
.observe(
{
viewState.postValue(MVIViewState.Success(it.result))
},
{
viewState.postValue(MVIViewState.Error(it.reason))
}
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.