subscribeStream method

void subscribeStream(
  1. StreamSink sink
)

Subscribes a Stream StreamSink to an Event.

This allows a sequence of broadcast Events to be represented and manipulated as a Stream. The rich range of mechanisms to filter and manipulate a Stream become available.

Remember that the supplied StreamSink should be closed when no longer needed.

// Example
 var e = Event();
 var sc = StreamController();

 e.subscribeStream(sc.sink);
 e.broadcast();

 sc.stream.listen((e) => print('boom'));
 sc.close();

Implementation

void subscribeStream(StreamSink sink) {
  _handlers.add((args) => {sink.add(args)});
}