Live reactive accessor for state data. Deeply nested changes trigger automatic updates, including array, Map, and Set mutations.
The current state
Add a handler function for when this state changes.
Listeners are invoked in the order they are registered and are passed a reference to the internally managed state object as a readonly object.
Do not modify state values directly. Instead, use set or patch to make immutable updates.
Returns a deep clone of the current state data using structuredClone() to
make the copy.
The object returned from this function can be edited without modifying the actual internal state.
Staticis
Powerful and flexible state management with deep reactivity, transaction, and locking support.
The State class wraps stateful data and provides an API for mutating the data while listeners subscribe to meaningful updates.