CoderObserver<T> class

CoderObserver is a utility class that allows non-widget listeners (e.g., services, background workers, etc.) to respond to state changes without rebuilding widgets.

It attaches to a CoderState and notifies all registered callbacks when the value changes.

Example usage:

final observer = CoderObserver(counterState);

observer.add((value) {
  print("Counter updated: $value");
});

// When no longer needed:
observer.dispose();

Constructors

CoderObserver(CoderState<T> state)
Constructor: starts listening to the state immediately.

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
state CoderState<T>
The state being observed.
final

Methods

add(CoderObserverCallback<T> callback) → void
Add a callback to be notified when the state changes.
dispose() → void
Dispose the observer to prevent memory leaks. Should be called when the observer is no longer needed.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
remove(CoderObserverCallback<T> callback) → void
Remove a previously added callback.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited