0

When building Android application in most update way MVI with Jetpack Compose we can do it by using Presenter or ViewModel. So let's consider 2 cases:

  1. MVI by MVP: We have this reactive stuff from MVI, including State and so on. For my understanding MVP as Presenter is bind to Activity/Fragment, so each has it's Presenter to present data. Correct my if I am wrong. In here adding state is quite obvious, we just add State, Intents/Events, Effect per one Connection (View -> Presenter). So if we have Screen in Compose it's also can have only one Presenter, we treat Screen like a Fragment

  2. MVI by MVVM: For me, one of rule of MVVM is that we can have multiple ViewModels per Activity/Fragment and ViewModel can be in multiple Activity/Fragment. In that case, in compose we also should be able to use multiples ViewModels per Screen and ViewModels in multiple Screen. Going further. Each Screen/View has it's own State, can produce it's won set Intent/Events and can take some set of Effects. Also ViewModels should be reusable so should update multiple, different States of Screen.

What do You think about using couple ViewModels in one Screen in MVI/MVVM ? What do You think about ViewModels updating different States (as every Screen has It's own State) ?

For me to make it possible we need to have one GlobalState containing States of each screen and each ViewModels can work with this GlobalState. In short, it's just need to be more in Redux style.

RippedLegDev
  • 1
  • 1
  • 3

0 Answers0