openEventStream method
Creates and returns a stream of Hako events.
This stream allows you to monitor all events that occur within this Hako container. Multiple listeners can subscribe to the same stream to receive notifications.
If called multiple times while the stream is open, this method will return the same stream instance. A new stream instance is only created when the previous stream has been closed via closeEventStream.
Returns a broadcast stream that will emit events until closeEventStream is called.
Implementation
Stream<HakoEvent> openEventStream() {
if (_eventStreamPair == null) {
final controller = StreamController<HakoEvent>();
final stream = controller.stream.asBroadcastStream();
_eventStreamPair = (sink: controller, stream: stream);
}
return _eventStreamPair!.stream;
}