emit<T extends EventType> method

void emit<T extends EventType>(
  1. T event
)

send the supplied event to all of the listeners that are subscribed to that EventType

Implementation

void emit<T extends EventType>(T event) {
  event.sanityCheck();
  List<dynamic>? targets = listeners[event.runtimeType];

  if (targets != null) {
    // avoid concurrent modification
    List<dynamic> copy = List<dynamic>.from(targets);

    copy.forEach((dynamic target) {
      try {
        //   logger.warn("invoking $event on $target");
        target(event);
      } catch (e, s) {
        logger.error(e.toString(), null, s);
      }
    });
  }
}