emit method

  1. @override
void emit(
  1. T val
)
override

Assigns a new value and notifies listeners if the value changed.

This method only notifies listeners if the new value is different from the current value (using != operator).

count.emit(5);        // Notifies if count.val != 5
count.emit(count.val + 1); // Increment and notify

The new value is also published to the stream.

Throws an assertion error in debug mode if called on a disposed signal.

Implementation

@override
void emit(T val) {
  super.emit(val);
  if (_isInitialized) {
    _saveToPersistence(val);
  }
}