https://kotlinlang.org logo
#compose
Title
# compose
g

Gonzalo Renedo

01/15/2023, 9:41 PM
I have a big viewModel for one screen, should i split them into more ViewModels? Or keep leaving a ViewModel for each screen?
s

Suser

01/16/2023, 3:20 AM
how big are we talking here?
m

Mod

01/16/2023, 6:58 AM
I suggest that you can try to implement use cases and you can take a look at the MVI pattern
o

okarm

01/16/2023, 8:05 AM
Let’s keep this channel focused on Compose.
g

Gonzalo Renedo

01/16/2023, 12:47 PM
405 lines
i have uses case for set and get data, should I implement uses case for all viewModel functions?
m

Mod

01/16/2023, 1:04 PM
it depends, if you can separate every functionality into use case that would be great but sometimes, I feel the use cases is overkill, as they just mapping to data layer with no extra logic so I suggest you check the MVI + MVVM pattern
g

Gonzalo Renedo

01/16/2023, 1:16 PM
Copy code
Yes, I use the vmmv pattern already, and quite a few use cases to call the repositories, I call the repositories directly from the VM because the use cases don't do anything, I've only left one use case because I need to make modifications before bring the data.
m

Mod

01/16/2023, 1:20 PM
try MVI then it will eliminate all the states you already defined in your view model and it will be one state class for your screen holding all the required info you need and an event class for the actions and you can map them in the view model I think this way it could be cleaner and easier and centralised
g

Gonzalo Renedo

01/16/2023, 1:25 PM
I don't know anything about MVI, why not MVVM?
m

Mod

01/16/2023, 1:25 PM
with MVVM
but your case that you have God view model
6 Views