emit<T> method

bool emit<T>(
  1. String type, [
  2. T? data
])

Emit a event with a specific event type and data type. This will broadcast the message to all listeners that match the same event type and data type.

  EventEmitter events = EventEmitter();
    ...
  events.emit('message', 'Hello World');

Same as emitEvent, but with a simpler syntax.

Implementation

bool emit<T>(String type, [T? data]) {
  if (data == null) return emitEvent(Event(type, null));
  return emitEvent(Event<T>(type, data));
}