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
yogaboy
09/10/2022, 8:16 PM
It’s depends. But my suggestion is do separate VM.
t
Tariyel Islami
09/10/2022, 8:36 PM
Yes, that’s how I did it. but it bothers me that I use the same functions in both viewModels.
m
mgrazianodecastro
09/11/2022, 4:36 AM
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.
mgrazianodecastro
09/11/2022, 4:37 AM
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
yogaboy
09/11/2022, 5:28 AM
If it is only about the same function use separate class UseCases and use the same method in VMs.