https://kotlinlang.org logo
u

ubu

10/24/2018, 9:55 AM
Hi there. I have a question concerning
AAC MVVM
implementation. I have an activity with several
view models
, and I need to connect these. Currently I use
activity
as a kind of proxy between them. But that feels wrong. What would be the best way for one
view model
to observe events from other
view model
? Or is it completely wrong way of implementing
MVVM architecture
?
Ah I misread, multiple VM in one view. You could always inject an instance of LiveData (or a subject if you’re using Rx) into each of them and observe those changes
t

trent

11/11/2018, 8:53 AM
I do this what OP says also. I guess one could delegate such connections to another class, but if Activity is light enough & some UI side-effects will be handled anyway then I don’t see what’s wrong with Activity connecting stuff 🤷
7 Views