invalidate method

void invalidate()

Forces a notification pass without changing the value.

Use this when subscribers must re-read the current value even though set would be a no-op due to value equality — for example:

  • a mutable object's fields changed without assigning a new reference
  • an external gate flipped (migration unlock, policy refresh) while auth/AsyncData identity stayed the same

Prefer a dedicated signal node or an explicit controller callback when the event is not really “this node’s value changed”; invalidate is the correct escape hatch when you intentionally want the same payload to re-fire ZenithSubscriber.onNodeChanged.

Contains a re-entrancy guard: if invalidate is called recursively from within a notification callback, the nested call is a no-op. This also protects against circular invalidation between two nodes.

Throws StateError if the node has been disposed.

Implementation

void invalidate() {
  if (_isDisposed) {
    throw StateError('Cannot invalidate a disposed ZenithNode');
  }

  if (_isInvalidating) {
    return;
  }

  _isInvalidating = true;
  try {
    notifySubscribers();
  } finally {
    _isInvalidating = false;
  }
}