Sign in Go Pro

Android MvRx Fundamentals

Initialize Your State Properties

This lesson is for PRO members.

Upgrade today to get access to all the PRO lessons.

Unlock this lesson

Up next



Although you can usually model your state such that it can be initialized with all default values, this isn't always practical. This lesson will introduce the concept of a MvRxViewModelFactory which enables you to hook into the MvRx lifecycle and assist MvRx in creating your initial state. MvRxViewModelFactory.initialState provides a ViewModelContext. A ViewModelContext provides access to the Fragment, Activity, and Application that is creating the ViewModel. You can use any of these to grab dependencies or arguments that are helpful in creating your initial state.




It would help a lot to have the source code!!


Lessons in Android MvRx Fundamentals