docs/debug-checks.md
Mavericks has a debug mode that enables some validation checks. These checks will safeguard against a number of common mistakes or other issues that could cause rare and hard to debug issues for real world users.
The checks include:
When you integrate Mavericks into your app, there are overloads to pass in Context or to explicitly set debugMode. If you initialize Mavericks with Context (recommended) then debug mode will automatically be enabled if your application is debuggable (context.applicationInfo.flags contains ApplicationInfo.FLAG_DEBUGGABLE).
withState/setStateAs all withState/setState blocks are processed sequentially, it's highly recommended to avoid slow calls inside these blocks (blocking IO/cpu consuming calls). You can use Android StrictMode to detect such calls. StrictMode.ThreadPolicy can be injected into MavericksViewModelConfigFactory.storeContextOverride:
val threadPolicy = StrictMode.ThreadPolicy.Builder()
.detectNetwork()
.penaltyDialog()
.build()
Mavericks.viewModelConfigFactory = MavericksViewModelConfigFactory(
this,
storeContextOverride = if (isDebuggable()) threadPolicy.asContextElement() else EmptyCoroutineContext
)