value property

  1. @override
T get value
override

The current value of the object.

When the value changes, the callbacks registered with addListener will be invoked.

Implementation

@override
T get value {
  Tracker.reportRead(this);

  return _value;
}
set value (T newValue)

Sets the current value and notifies listeners.

The write is ignored when the signal is disposed or when the new value is judged equal to the current one (by equals, falling back to ==).

Inside a batch the guard covers the group: the notification carries the value the signal held when the batch first wrote to it, so a batch that moves the value and puts it back notifies nobody.

Implementation

set value(T newValue) {
  if (_disposed || isEqual(_value, newValue, equals: _equals)) return;

  final T previous = _value;
  _value = newValue;

  Propagation.run(() {
    for (final ReactiveNode dependent in _dependents.toList()) {
      dependent.markStale();
    }

    Propagation.emit(this, () => _notify(previous));
  });
}