Skip to content

Instantly share code, notes, and snippets.

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