Skip to content

Instantly share code, notes, and snippets.

@marcinOz
Created June 14, 2018 11:19
Show Gist options
  • Save marcinOz/5125b244e06fc296f85efd9e38e0ebb8 to your computer and use it in GitHub Desktop.
Save marcinOz/5125b244e06fc296f85efd9e38e0ebb8 to your computer and use it in GitHub Desktop.
//MovieListViewModel
val movieDiscover = MutableLiveData<ResourceState<List<Movie>>>()
//View
private fun updateView(resourceState: ResourceState<List<Movie>>) = when(resourceState) {
is LoadingState -> showLoading(true)
is PopulatedState -> populate(resourceState.data)
is EmptyState -> showEmptyMessage()
is ErrorState -> showError(resourceState.message)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment