flushEffects function

void flushEffects()

Runs every effect currently queued for notification.

The queue is drained in order. If an effect throws, remaining queued effects are restored to a watchable state before the queue is reset.

Implementation

@pragma("vm:prefer-inline")
@pragma("wasm:prefer-inline")
@pragma("dart2js:prefer-inline")
@pragma("vm:align-loops")
@pragma('vm:unsafe:no-bounds-checks')
void flushEffects() {
  try {
    while (notifyIndex < queuedLength) {
      final effect = queued[notifyIndex]!;
      queued[notifyIndex++] = null;
      effect.run();
    }
  } finally {
    while (notifyIndex < queuedLength) {
      final effect = queued[notifyIndex]!;
      queued[notifyIndex++] = null;
      effect.flags |= ReactiveFlags.watching | ReactiveFlags.recursed;
    }
    notifyIndex = 0;
    queuedLength = 0;
  }
}