addAppEventListener function
Subscribes listener to every event reported from now on, and returns the
call that unsubscribes it.
The seam a live surface uses, where a scenario run uses appEventBuffer.
A devbar registers one while it is mounted; a project can register its own.
Pass ignoreSource to skip events a particular reporter tagged, for a
surface that reporter already handed a copy to directly. That is how a
devbar avoids listing a DevbarHttpClient request twice — it is given the
exchange in two halves as it happens, so it ignores the one-piece report
the same client makes for everybody else.
A listener that throws is reported to the current Zone and skipped; it never reaches the app code that called recordAppEvent.
Applies no cap of its own — a live surface keeps whatever history it wants, and the devbar's tabs already bound theirs.
Implementation
void Function() addAppEventListener(
void Function(AppEvent) listener, {
Object? ignoreSource,
}) {
var registration = _Registration(listener, ignoreSource);
_listeners.add(registration);
return () => _listeners.remove(registration);
}