Skip to content

Instantly share code, notes, and snippets.

@BaranMichal25
Last active Oct 28, 2018
Embed
What would you like to do?
Article 2, Point 1.2
class BooksFragment : Fragment() {
...
override fun onActivityCreated(savedInstanceState: Bundle?) {
super.onActivityCreated(savedInstanceState)
viewModel = ViewModelProviders.of(this).get(BooksViewModel::class.java)
viewModel.liveData.observe(viewLifecycleOwner, Observer { updateViews(it) }) // Usually what we want: Passing Fragment's view as LifecycleOwner
}
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment