emit method
- T val
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
void emit(T val) {
assert(!isDisposed, 'Cannot emit on a disposed Signal');
if (value != val) {
value = val;
_streamController?.add(val);
}
}