asStream method

Stream<HookedServiceEvent<Id, Data, T>> asStream()

Returns a Stream containing all events fired by this dispatcher.

NOTE: Callbacks on the returned Stream cannot be guaranteed to run before other listeners. Use this only if you need a read-only stream of events.

Implementation

Stream<HookedServiceEvent<Id, Data, T>> asStream() {
  var ctrl = StreamController<HookedServiceEvent<Id, Data, T>>();
  _ctrl.add(ctrl);
  listen(ctrl.add);
  return ctrl.stream;
}