forEach method
void
forEach(
- void callback(
- T event
Invokes callback for every unread event without allocating a result
list, then advances this reader's cursor.
Events sent by the callback remain unread until the next read.
If callback throws, the cursor is left unchanged so the unread events can
be retried.
Disposing this reader from a callback stops delivery of the batch.
Implementation
void forEach(void Function(T event) callback) {
final channel = _activeChannel;
final from = _cursor - channel._base;
final start = from < 0 ? 0 : from;
final end = channel._events.length;
final endCursor = channel._base + end;
for (var i = start; i < end; i++) {
if (isDisposed) return;
callback(channel._events[i]);
}
_cursor = endCursor;
}