Shared view model is a common pattern, when you us...
# android-architecture
g
Shared view model is a common pattern, when you use activity's VM in the fragment. What if the fragment itself has a viewmodel and they need to communicate? Do you link them on the fragment level, or you pass activity VM inside the fragment VM?
a
I'm working on a project where I passed the activity VM to the fragment VM when its constructed. That worked fine for me, though I'm not sure if it introduced any memory issues...
s
Maybe a VM reducer?
g
@sam so you mind to elaborate?
s
Basically what you said something that's taking in two ViewModels at the fragment level and giving you back the state you need
🙏 1