on method

void on(
  1. EventType event,
  2. void listener(
    1. dynamic
    )
)

Listens to specific events by name.

Implementation

void on(EventType event, void Function(dynamic) listener) {
  final subscription = _controller.stream
      .where((eventMap) => eventMap.containsKey(event))
      .map((eventMap) => eventMap[event])
      .listen(listener);

  _listeners.putIfAbsent(event, () => []).add(MapEntry(listener, subscription));
}