applyExternalStates

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

Deprecated

Use externalState()?.hydrate(states, HydrateSource.External("DevTools")), which exists only when the store grants outside state.

Replace with

externalState()?.hydrate(states, HydrateSource.External("DevTools"))

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