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

setState

fun <VM : MavericksViewModel<S>, S : MavericksState> setState(viewModel: VM, state: S): Unit

A helper to set a state on a view model via MavericksStateStore.set.

This may not work if the ViewModel's state store is mocked or configured to not accept state changes, and it is the responsibility of the caller to make sure that the state store can accept changes.

Additionally, it is the responsibility of the caller to understand the type of state store the view model is using, and whether the state change will take affect synchronously or asynchronously depending on the state store implementation.

See setScriptableState if you want to force a state on a ScriptableStateStore that would otherwise not allow state changes.