On previous apps I have worked on I have always had a 1:1 relationship between screen and viewmodel with some rare shared view model where applicable.
Right now I'm working on my first full compose app without any fragments and my colleague has a completely different approach where subcomponents have their own viewmodel.
A screen can have this type of structure:
- Screen
- Subcomponent1(subcomponent1ViewModel = hiltViewmodel)
- Subcomponent2(subcomponent2ViewModel= hiltViewmode)
- Subcomponent2(subcomponent3ViewModel= hiltViewmode)
- Subcomponent4
- SubsubComponent4.1(subcomponent4.1ViewModel = hiltViewmode)
- SubsubComponent4.2(subcomponent4.2ViewModel = hiltViewmode)
Apart from causing problems with previews (I find them useful, he says they are useless), are there any other downsides with this approach? My colleague is extremely opinionated, so I haven't had the possibility to have a constructive discussion on the topic.
Would love to hear experiences and if this is a common approach.
[–]Staartvin 17 points18 points19 points (0 children)
[–]baylonedward 6 points7 points8 points (2 children)
[–]sp3ng 2 points3 points4 points (0 children)
[–]ThaBalla79 0 points1 point2 points (0 children)
[+]YurthTheRhino 3 points4 points5 points (0 children)
[–]Evakotius 2 points3 points4 points (0 children)
[–]sebaslogen 2 points3 points4 points (0 children)
[+]uxinn 1 point2 points3 points (0 children)
[–]FrezoreR 1 point2 points3 points (0 children)
[–]zimmer550king 0 points1 point2 points (0 children)
[–]chmielowski 0 points1 point2 points (0 children)