I have adjusted my repository to make it a protected variable. Great idea!

The MainViewModel is not required in this example. I included it in order to have a clear separation between the view logic in the Activity and the “Business logic” in the MainViewModel. Per your suggestion, passing in the repository into the MainViewModel; the reason I’m injecting the repository in the MainViewModel is to keep the “Business logic” apart from the UI in the MainActivity.

Open Sourcer

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store