Pingora class

The base class for creating ViewModels / Controllers that can notify listeners about state changes.

Extend this class to create a stateful controller, then use subscribe to listen for updates, ping to notify all listeners, unsubscribe to remove a listener, and dispose to permanently shut down the controller.

class CounterModel extends Pingora {
  int count = 0;

  void increment() {
    count++;
    ping(); // notify all subscribers
  }
}

Once dispose is called, any further calls to subscribe, unsubscribe, or ping will throw an AssertionError to catch bugs early.

Constructors

Pingora()

Properties

hashCode → int
The hash code for this object.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

dispose() → void
Permanently disables this Pingora.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
ping() → void
Notifies all currently subscribed listeners by calling each one.
subscribe(VoidCallback listener) → void
Registers a listener that will be called every time ping is invoked.
toString() → String
A string representation of this object.
inherited
unsubscribe(VoidCallback listener) → void
Removes a previously registered listener.

Operators

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