Package-level declarations

Types

Link copied to clipboard

The receiver of a RoutingBuilder.model block; registers single-model handlers for model type M.

Link copied to clipboard
typealias OnWrite = (action: Any, modelClass: KClass<*>, prev: Any, next: Any, source: String) -> Unit

Observer invoked for every effective model write during a dispatch, i.e. only when the new instance is referentially different (next !== prev). Fired synchronously during the fold, before the dispatch commits, so under last-write-wins it can observe intermediate (clobbered) values. It MUST be a pure observer: it must not call dispatch or read the store.

Link copied to clipboard
interface Reads

A read-only view of model state passed to multi-model handlers during a dispatch. Reads reflect writes already produced by earlier handlers in the same dispatch (fold semantics), so a later handler observes prior handlers' results.

Link copied to clipboard
@Target(allowedTargets = [AnnotationTarget.FUNCTION])
annotation class Reduce

Marks a top-level single-model reducer handler of shape (M, A) -> M, to be collected by the redux-kotlin-routing-codegen KSP processor and emitted as an on<A> registration for model M. Matching is by the action's exact leaf class.

Link copied to clipboard
@Target(allowedTargets = [AnnotationTarget.FUNCTION])
annotation class ReduxInitial

Marks a top-level zero-argument provider of a model's initial instance (() -> M). Exactly one @ReduxInitial per model type must exist in the same module as that model's Reduce handlers; the generated registrar calls it to seed the model via model(provider()).

Link copied to clipboard
fun interface ReduxModule

A reusable bundle of model and handler registrations that can be installed into a RoutingBuilder. Lets feature modules package their slice of the store; the app fixes ordering by the sequence of install calls.

Link copied to clipboard

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.

Link copied to clipboard
class WriteSet

The set of model replacements returned by a multi-model handler (onAction). Each entry replaces one model slot; a model not named here is left untouched. Build instances with writeSet.

Link copied to clipboard

Builder for WriteSet; the receiver of the writeSet lambda.

Functions

Link copied to clipboard
fun createModelStore(enhancer: StoreEnhancer<ModelState>? = null, devChecks: Boolean = false, onWrite: OnWrite? = null, preloadedState: ModelState? = null, block: RoutingBuilder.() -> Unit): Store<ModelState>

Builds a Store of ModelState from a routing block. Each model's starting value comes from its RoutingBuilder.model declaration; there is no INIT-action fan-out. Dispatch routes by the exact leaf class of the action.

Link copied to clipboard
inline fun <M : Any> Reads.get(): M

Reified convenience for Reads.get.

Link copied to clipboard

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

Link copied to clipboard

Builds a WriteSet from a sequence of WriteSetBuilder.set calls.