notifySignal<T> function

void notifySignal<T>(
  1. SignalReactiveNode signal
)

Invalidates a signal so that subscribers re-evaluate without changing the stored value.

Parameters:

  • signal: Signal to invalidate

Example:

final cacheAwareSignal = CustomSignalNode<int>(0);
notifySignal(cacheAwareSignal);

Implementation

@pragma("vm:prefer-inline")
@pragma("wasm:prefer-inline")
@pragma("dart2js:prefer-inline")
void notifySignal<T>(SignalReactiveNode signal) {
  // Mark as changed even if the underlying reference didn't change (e.g. in-place mutations).
  signal.flags = ReactiveFlags.mutable | ReactiveFlags.dirty;

  signal.cachedValue = null;

  final subs = signal.subs;
  if (subs != null) {
    propagate(subs);
    shallowPropagate(subs);
    if (batchDepth == 0) {
      flushEffects();
    }
  }

  JoltDebug.notify(signal);
}