Skip to content

Instantly share code, notes, and snippets.

@makorowy
Last active October 18, 2020 09:46
Show Gist options
  • Save makorowy/72f14a187dd5a8fc30350811f527d779 to your computer and use it in GitHub Desktop.
Save makorowy/72f14a187dd5a8fc30350811f527d779 to your computer and use it in GitHub Desktop.
Example of not handling interactions via ViewModel, part 5
class Fragment : Fragment() {
@Inject
lateinit var viewModel: ViewModel
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
viewModel.liveData.observe(this, Observer { data -> /* update the view */ })
backButton.setOnClickListener { viewModel.onInteraction(Interaction.BackButtonClick) }
skipButton.setOnClickListener { viewModel.onInteraction(Interaction.SkipButtonClick) }
//...
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment