mvrx-mocking / com.airbnb.mvrx.mocking / MockableMavericks / initialize

initialize

fun initialize(context: Context): Unit

Initializes the required Mavericks.viewModelConfigFactory and sets ViewModel debug and mock behavior for the app.

If the application was built with the debuggable flag enabled in its Android Manifest then this will add plugins to Mavericks that enable working with mock State. This is useful for both manual and automated testing of development builds.

This function is a shortcut instead of setting each property in this object individually. For custom control you can set properties directly instead.

It is safe to call this in both debug and production builds and it will take care of the correct behavior for you.

The context will be used to automatically register a broadcast receiver for each ViewModel created in the app with ViewModelStatePrinter so that the state printing system is automatically enabled.

Calling this subsequent times will replace the plugins with new instances.

fun initialize(mocksEnabled: Boolean, debugMode: Boolean, context: Context?): Unit

Initializes the required Mavericks.viewModelConfigFactory and sets ViewModel debug and mock behavior for the app.

Choose whether to enable Mavericks mocking tools. This is useful for both manual and automated testing of development builds.

This function is a shortcut instead of setting each property in this object individually. For custom control you can set properties directly instead.

The context will be used to automatically register a broadcast receiver for each ViewModel created in the app with ViewModelStatePrinter so that the state printing system is automatically enabled.

Calling this subsequent times will replace the plugins with new instances.

Parameters

debugMode - True if debug checks should be enabled

mocksEnabled - True if ViewModel mocking should be enabled.

context - Application context. If provided this will be used to register a ViewModelStatePrinter for each ViewModel to support mock state printing.