set method

void set(
  1. T newValue
)

Sets a new value for the signal.

If the new value differs from the pending value, marks the signal as dirty and propagates changes to all subscribers.

If not in a batch (batchDepth == 0), immediately flushes all queued effects.

Implementation

void set(T newValue) {
  if (!identical(pendingValue, newValue)) {
    pendingValue = newValue;
    flags =
        17 /*ReactiveFlags.mutable | ReactiveFlags.dirty*/ as ReactiveFlags;
    if (subs case final Link subs) {
      propagate(subs);
      if (batchDepth == 0) flush();
    }
  }
}