notifyEffect method

void notifyEffect()

Enqueues this effect and parent watching effects for execution.

Called by the propagation system when this node is marked ReactiveFlags.watching. Parent effects are inserted ahead of children to preserve cleanup and run order.

Implementation

void notifyEffect() {
  BaseEffectNode? effect = this;

  var insertIndex = queuedLength;
  var firstInsertedIndex = insertIndex;

  // allow do-while loop
  // ignore: literal_only_boolean_expressions
  do {
    effect!.flags &= ~ReactiveFlags.watching;

    // queued[insertIndex++] = effect;
    setEffectQueue(insertIndex++, effect as EffectNode?);
    effect = effect.subs?.sub as BaseEffectNode?;
    if (effect == null || effect.flags & (ReactiveFlags.watching) == 0) {
      break;
    }
  } while (true);

  queuedLength = insertIndex;

  while (firstInsertedIndex < --insertIndex) {
    final left = queued[firstInsertedIndex];
    // queued[firstInsertedIndex++] = queued[insertIndex];
    setEffectQueue(firstInsertedIndex++, queued[insertIndex]);
    queued[insertIndex] = left;
  }
}