RoutingBuilder

Collects model initial instances and action handlers, then produces the initial ModelState and the routed Reducer. This is the receiver of the createModelStore lambda and of ReduxModule contributions. Registration order across the whole block (including installed modules) fixes the dispatch order for any action handled by more than one handler.

Functions

Link copied to clipboard

Applies a ReduxModule's registrations to this builder, in call order.

Link copied to clipboard
inline fun <M : Any> model(initial: M, block: ModelHandlerScope<M>.() -> Unit)

Registers a model of type M with its initial instance and its single-model handlers. The initial instance is the sole source of that model's starting value — there is no INIT action fan-out.

Link copied to clipboard
inline fun <A : Any> onAction(noinline handler: (reads: Reads, action: A) -> WriteSet)

Registers a multi-model handler for action A. The handler reads any models via Reads and returns a WriteSet of replacements. The handler must be pure: it must not call dispatch or read the store, only compute the next models from its inputs.

Link copied to clipboard
inline fun <A : Any> onBroadcast(noinline transform: (model: Any, action: A) -> Any)

Registers a broadcast handler for action A that runs once per installed model. transform receives each model instance and returns its (possibly unchanged) replacement. Use for cross-cutting actions such as reset/logout that every model must observe. The transform must be pure: it must not call dispatch or read the store, only compute the next model from its inputs.