-
Notifications
You must be signed in to change notification settings - Fork 500
Integrating MvRx In Your App
MvRx ships with a BaseMvRxActivity that has the necessary setup code. It is recommended that you make your base activity just extend this. It adds very little overhead when not using MvRx and ensures that things will be set up correctly.
If this is not practical for your app, you can copy implementation details from that class into your own base Activity.
Similar to your Activity, MvRx ships with a BaseMvRxFragment that has the necessary setup code. It is recommended that you make your base activity just extend this. It adds very little overhead when not using MvRx and ensures that things will be set up correctly.
If this is not practical for your app, you can copy implementation details from that class into your own base Fragment.
MvRx runs a number of debug checks to ensure that your usage of MvRx is correct. In order for that to run, you must create your own base ViewModel that passes in the correct value for debugMode
.
An example of this would look like this:
abstract class MvRxViewModel<S : MvRxState>(initialState: S) : BaseMvRxViewModel<S>(initialState, debugMode = BuildConfig.DEBUG)
All this does is ensure that the debug checks are run at the right time and exposes a new ViewModel for your features to extend.