StateChangeListener<TState> typedef

StateChangeListener<TState> = void Function(TState prevState, TState state)

Invoked by State.subscribe on every state transition.

Receives the value before the write and the value after — useful for diffing (e.g. "only fire when the user field changed"). Listeners run synchronously from State.state's setter.

Implementation

typedef StateChangeListener<TState> =
    void Function(TState prevState, TState state);