Skip to content

Instantly share code, notes, and snippets.

@marcinOz
Created June 14, 2018 11:04
Show Gist options
  • Save marcinOz/c086a4306439b4b9033543556f6e761e to your computer and use it in GitHub Desktop.
Save marcinOz/c086a4306439b4b9033543556f6e761e to your computer and use it in GitHub Desktop.
movieDiscover.observe(activity, Observer { it?.apply { updateView(this) }})
private fun updateView(resourceState: ResourceState) = when(resourceState) {
is LoadingState -> showLoading(true)
is PopulatedState<*> -> populate(resourceState.data as List<Movie>)
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