registerAll method

  1. @override
Stream<Event> registerAll(
  1. [bool includeLastEvent = false]
)
override

Listens for events of all subtypes of Event.

The method is called like this: eventBus.registerAll();

The returning Stream contains every event of this EventTaxi. if includeLastEvent is true the stream will emit the last event with If there is no last event it won't to anything.

Implementation

@override
Stream<Event> registerAll([bool includeLastEvent = false]) {
  assert(!_eventBusIsAlreadyClosed, "EventBus is already closed");

  /// If this is the first time listening to this event, the list is null
  _streamEventMap[_allEventsKey] ??= [];

  EventController<Event> controller =
      _createAndAddController(includeLastEvent, _allEventsKey);

  /// If the [previousEvent] parameter is set to true, we add the last event to the [EventController]
  if (includeLastEvent) {
    controller.add(_lastEvents.values.last);
  }

  return controller.stream.asBroadcastStream();
}