class CompoundObserver


CompoundObserver is a Bindable object which knows how to listen to multiple values (registered via addPath or addObserver) and invoke a callback when one or more of the values have changed.

var obj = new ObservableMap.from({'a': 1, 'b': 2}); var otherObj = new ObservableMap.from({'c': 3});

var observer = new CompoundObserver()

 ..addPath(obj, 'a');
 ..addObserver(new PathObserver(obj, 'b'));
 ..addPath(otherObj, 'c');
 ..open((values) {
   for (int i = 0; i < values.length; i++) {
     print('The value at index $i is now ${values[i]}');
   }
 });

obj'a' = 10; // print will be triggered async

Implements
  • Bindable

Constructors

CompoundObserver([bool _reportChangesOnOpen = false])

Properties

hashCode → int

Get a hash code for this object.

read-only, inherited
runtimeType → Type

A representation of the runtime type of the object.

read-only, inherited
value → dynamic

Gets the current value of the bindings. Note: once the value of a Bindable is fetched, the callback passed to open should not be called again with this new value. In other words, any pending change notifications must be discarded.

read / write, inherited
value → dynamic

read-only, inherited

Operators

operator ==(other) → bool

The equality operator.

inherited

Methods

addObserver(Bindable observer) → void

addPath(Object object, [path]) → void

Adds a dependency on the property path accessed from object. path can be a PropertyPath or a String. If it is omitted an empty path will be used.

close() → void

Stops future notifications and frees the reference to the callback passed to open, so its memory can be collected even if this Bindable is alive.

inherited
deliver() → void

Deliver changes. Typically this will perform dirty-checking, if any is needed.

inherited
noSuchMethod(Invocation invocation) → dynamic

Invoked when a non-existent method or property is accessed.

inherited
open(callback) → dynamic

Initiates observation and returns the initial value. The callback will be passed the updated value, and may optionally be declared to take a second argument, which will contain the previous value.

toString() → String

Returns a string representation of this object.

inherited