--

Hi Mahan, thanks for the reference. Long story short ideally the ViewModel should just be "the model of the view", meaning it should contact data sources, collect the necessary data and map it to the UI models. This can be done by calling apis/repos/usecases/etc. It really depends what is your case and what is good/bad for your architecture at the moment. The same goes for interaction with Android dependencies, like Fragment, Navigation, Lifecycle, etc. The VM should only model the data that for ex. Fragment observes and then knows that the app should navigate. This can be done in multiple ways, but the easiest and most straightforward one is to just emit events from VM that are observed in Fragment.

--

--

Patryk Kosieradzki
Patryk Kosieradzki

Written by Patryk Kosieradzki

Senior Android &iOS Engineer @ Moss, based in Warsaw, Poland

Responses (1)