forEach method

void forEach(
  1. void callback(
    1. T event
    )
)

Invokes callback for every unread event without allocating a result list, then advances this reader's cursor.

If callback throws, the cursor is left unchanged so the unread events can be retried.

Implementation

void forEach(void Function(T event) callback) {
  final from = _cursor - _channel._base;
  final start = from < 0 ? 0 : from;
  final end = _channel._events.length;
  for (var i = start; i < end; i++) {
    callback(_channel._events[i]);
  }
  _cursor = _channel._end;
}