Skip to content

Instantly share code, notes, and snippets.

@YashishDua
Created November 17, 2018 12:37
Show Gist options
  • Save YashishDua/5d359cacb55e7628d2bb98fd3a9f80aa to your computer and use it in GitHub Desktop.
Save YashishDua/5d359cacb55e7628d2bb98fd3a9f80aa to your computer and use it in GitHub Desktop.
class WallDetailFragment : Fragment() {
private lateinit var model: SharedViewModel
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
model = activity?.run {
ViewModelProviders.of(this).get(SharedViewModel::class.java)
} ?: throw Exception("Invalid Activity")
model.data.observe(this, Observer<Item> { item ->
// Update the UI
})
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment