Skip to content

Instantly share code, notes, and snippets.

@seanghay
Last active June 27, 2020 09:55
Show Gist options
  • Save seanghay/8ebc0b800123af055c025e420c36b635 to your computer and use it in GitHub Desktop.
Save seanghay/8ebc0b800123af055c025e420c36b635 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 ->
val (items) = result.withDefault { postsFromDb() }
adapter.submitList(items)
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment