Skip to content

Instantly share code, notes, and snippets.

@adam-hurwitz
Last active July 7, 2020 20:58
Show Gist options
  • Save adam-hurwitz/dd977bccd2a7693f443df7a0bc7083ea to your computer and use it in GitHub Desktop.
Save adam-hurwitz/dd977bccd2a7693f443df7a0bc7083ea to your computer and use it in GitHub Desktop.
Optimizing ViewModel with Lifecycle 2.2.0: Declaring VM val
class Fragment : Fragment() {
private val viewModel: SomeViewModel by viewModels()
private fun observeViewState() {
viewModel.viewState.observe(viewLifecycleOwner) { viewState ->
//viewState used here.
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment