Skip to content

Instantly share code, notes, and snippets.

@seanghay
Last active September 22, 2020 18:24
Show Gist options
  • Save seanghay/7eeb6b84710f2820f9baca0c5b9855b7 to your computer and use it in GitHub Desktop.
Save seanghay/7eeb6b84710f2820f9baca0c5b9855b7 to your computer and use it in GitHub Desktop.
/* Copyright 2020 Seanghay Yath (@seanghay)
SPDX-License-Identifier: Apache-2.0 */
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
viewModel.posts.observe(viewLifecycleOwner, Observer {result ->
result.doIfSuccess {items ->
adapter.submitList(items)
}
result.doIfFailure {message, throwable ->
showErrorMessage(message ?: "Unknown error message")
}
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment