notify method

void notify(
  1. void report(
    1. Object error,
    2. StackTrace stackTrace
    )
)

Calls every active listener in subscription order, synchronously.

Iterates over a snapshot of entries. A listener removed during the pass is skipped; one added during the pass hears the next change. Each call is isolated: an error thrown by a listener is handed to report, and the pass continues.

Implementation

void notify(void Function(Object error, StackTrace stackTrace) report) {
  if (_entries.isEmpty) {
    return;
  }
  final snapshot = _entries.toList();
  for (final entry in snapshot) {
    if (!entry.alive) {
      continue;
    }
    try {
      entry.listener();
    } on Object catch (error, stackTrace) {
      report(error, stackTrace);
    }
  }
}