Signals and derived values
Reactive transformations of state that the renderer subscribes to directly.
A Signal[T] is any reactive value whose changes can be subscribed to. The
interface is:
Signals are produced by StateValue.Format and Derived.
Format signals
StateValue[T].Format(format) produces a Signal[string] by applying
fmt.Sprintf(format, current). When you pass it to Text, the renderer
subscribes and patches the label in place.
Derived signals
Derived[T, U] transforms a *StateValue[T] into a Signal[U].
The transformation runs eagerly once at creation time and again each time the source state changes.
Derived lists
DerivedList is a specialization that returns a *StateValue[[]T] instead
of a Signal[[]T], so you can pass the result to List or ListOf.
The derived state is read-only in practice; mutate the source state and the derived slice updates automatically.
Text accepts either a string or a Signal[string]
The Text constructor is Text(content any). It type-switches on the
argument:
stringrenders as static text.Signal[string](produced byFormatorDerived) renders reactively.
Any other type panics at construction time.