applyExternalStates

abstract suspend fun applyExternalStates(states: Map<String, ModuleState>)(source)

Deprecated

Dispatch StoreAction.Hydrate instead, so external state is ordered against every other dispatch rather than written alongside the pipeline.

Replace with

dispatchAndAwait(StoreAction.Hydrate(states, "External"))

Replaces the state of the named modules without running their reducers.

Delegates to StoreAction.Hydrate, which the store applies from its dispatch loop, so the update is ordered against every other dispatch rather than written alongside them.

Each module's state is written to its own kotlinx.coroutines.flow.MutableStateFlow, so a single module's update is atomic, but the map is not applied as one transaction: a collector of one module can observe its new value before another module in the same call has been written.

Example usage:

storeAccessor.dispatchAndAwait(
StoreAction.Hydrate(
states = mapOf("com.example.CounterState" to CounterState(value = 42)),
origin = "DevTools"
)
)

Parameters

states

Map of state class qualified names to new state instances