subscribe method

void subscribe(
  1. Stream stream
)

Invokes Stream.listen on the provided Stream and propagates emitted data to the onData, onError, and onDone methods.

Note: All StreamListenerMixin instances which invoke subscribe must also invoke cancel in order to cancel all pending StreamSubscriptions.

Implementation

void subscribe(Stream stream) {
  _subscriptions.add(stream.listen(
    (data) => onData(stream, data),
    onDone: () => onDone(stream),
    onError: (error, stackTrace) => onError(stream, error, stackTrace),
    cancelOnError: cancelOnError(stream),
  ));
}