doOnEach method

Stream<T> doOnEach(
  1. void onEach(
    1. Notification<T> notification
    )
)

Invokes the given callback function when the stream emits data, emits an error, or emits done. The callback receives a Notification object.

The Notification object contains the Kind of event (OnData, onDone, or OnError), and the item or error that was emitted. In the case of onDone, no data is emitted as part of the Notification.

Example

Stream.fromIterable([1])
  .doOnEach(print)
  .listen(null); // prints Notification{kind: OnData, value: 1, errorAndStackTrace: null}, Notification{kind: OnDone, value: null, errorAndStackTrace: null}

Implementation

Stream<T> doOnEach(void Function(Notification<T> notification) onEach) =>
    DoStreamTransformer<T>(onEach: onEach).bind(this);