Sign in Go Pro

Android MvRx Fundamentals

Share ViewModels Across Fragments

This lesson is for PRO members.

Upgrade today to get access to all the PRO lessons.

Unlock this lesson

Up next



So far, our ViewModel has been scoped to a single Fragment. However, MvRxViewModels are great for sharing data across screens within an Activity. To share a ViewModel across screens, all you have to do is change your ViewModel property delegate from fragmentViewModel() to activityViewModel().
This lesson will walk through:
* fragmentViewModel()
* activityViewModel()
* existingViewModel()




I'm not sure where or how you created the two containers. I've attempted to create the two containers, but only one builds on the screen.


Lessons in Android MvRx Fundamentals