Is this Anti pattern : having two ViewModel in Fr...
# android
Is this Anti pattern : having two ViewModel in Fragment or Activity . I don't think so, I have a certain common things let's permission handling in One PermissionVm which I'll be using in multiple activities . I think this is Ok. What you guys think about that??
stackoverflow 1
google 1
Why not use 1 VM with 2 UseCase classes (1 for permission stuff and another for other stuff) and provide 2 LiveDatas? I think the question really is: What is the single purpose of the ViewModel? To me: It's to hold and keep the UI state for the whole screen being shown. For you, maybe the answer is different.
☝️ 1
Well permissions you need context ..Using context in use case is not ideal though
It's not ideal in a view model either though. I think for permissions, maybe a view model isn't ideal at all. How about using the permissions API directly?
In the sense of MVVM, yes, two viewmodels for one screen is an anti pattern
@Afzal Najam then we have to duplicate those in each activities
View can listen to multiple source for update .. so how come this is in Anti Pattern
Where is written like that @Orhan Tozan