subscribeStream method
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(String key, StreamSink sink) {
if (sink is! StreamSink) {
throw ArgumentError('a Sink must be specified');
}
_handlers[key] = ((args) => {sink.add(args)});
}