Hi guys, I’m doing the Instagram clone. I’m stuck ...
# compose
t
Hi guys, I’m doing the Instagram clone. I’m stuck in the User section. There has to be a current user and other users. Do I need to do all the operations in a single UserViewmodel or do I need to separate them as CurrentUserViewModel and otherUserViewModel? Or How should be best practice?
y
It’s depends. But my suggestion is do separate VM.
t
Yes, that’s how I did it. but it bothers me that I use the same functions in both viewModels.
m
is the implementation details different? If so, you can feel more comfortable by creating an interface for UseViewModel, and extend the two implementations from it.
if they literally do the same thing on almost every case, I'd use a feature flag from a sealed class to define the behave on the specific cases
y
If it is only about the same function use separate class UseCases and use the same method in VMs.