Hydrate

data class Hydrate : StoreAction(source)

Replaces the state of the named modules.

This is how state arrives from outside the store: a remote publisher projecting onto a follower, or persisted state being restored. It carries state rather than intent, so no module logic runs and no side effect is repeated. Re-dispatching the original actions would do both, which is why replication projects state instead.

Entries naming an unregistered module, or carrying a state of the wrong type for the module they name, are skipped with a warning rather than failing the dispatch.

Usage:

store.externalState()?.hydrate(
states = mapOf("com.example.CounterState" to CounterState(value = 42)),
source = HydrateSource.External("DevTools")
)

Parameters

states

New state per module, keyed by the state class's qualified name.

source

What produced this state. Only HydrateSource.Restore is applied by a store that does not grant outside state.

Constructors

Link copied to clipboard
constructor(states: Map<String, ModuleState>, origin: String)

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard