Observable State Container
Decorator that adds observer capability to any StateContainer.
This wrapper allows any StateContainer implementation to support state change notifications through the observer pattern. Observers are notified only after successful state updates.
Parameters
The type of state being managed
Properties
Functions
Adds an observer to receive state change notifications.
Removes all observers.
Conditionally updates the state only if the current state matches the expected state.
Updates the state and returns the previous state if successful, or null if failed.
Returns the current state cast to the specified type, or null if not of that type.
Returns true if the current state is of the specified type.
Adds an observer that only reacts to actual state changes (not same state).
Adds an observer that only cares about the new state.
Removes an observer from receiving state change notifications.
Updates the state and returns the new state if successful, or null if failed.
Extension function for StateContainer to perform atomic updates.
Updates the state using the provided updater function.
Transforms the state using a suspending function while maintaining thread safety.
Validates the given state using the container's validator.