Last active
October 18, 2020 09:46
-
-
Save makorowy/72f14a187dd5a8fc30350811f527d779 to your computer and use it in GitHub Desktop.
Example of not handling interactions via ViewModel, part 5
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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