One application state value with pure transitions, cached projections and an optional undo/redo history — sugar over a Signal and Computeds, not a second reactive system.
final case class Todo(items: Vector[String], filter: String)
private val store = Store(Todo(Vector.empty, ""), history = 50)
private val shown = store.select(s => s.items.filter(_.contains(s.filter)))
def view(using ReactiveScope, Theme): Element =
column(list(shown.get, state), button("undo")(store.undo()))
store.dispatch(s => s.copy(items = s.items :+ "write docs"))
dispatch applies action to the current state and publishes the result; an action that produces a state the signal's SignalEquality calls unchanged notifies nobody and records no history entry. select is a long-lived Computed: create it once beside the store, not inside view, and dispose it with the store's owner — the contract is the one on Computed. With history > 0 the store keeps up to that many previous states; undo steps back through them and redo forward again until the next dispatch, which discards the redo branch.
Ownership and threads: the render-thread rules of Signal and Computed apply unchanged. dispatch, undo, redo, select and get are render-thread calls (or runner-less unit-test calls); peek may be read from any thread. The history is plain mutable state touched only on that same thread.
Applies a pure transition and publishes the result. A transition that changes nothing is a no-op in every sense: no notification, no history entry, no redo branch discarded.
Applies a pure transition and publishes the result. A transition that changes nothing is a no-op in every sense: no notification, no history entry, no redo branch discarded.