fire<T> method

bool fire<T>(
  1. EventKey<T> key,
  2. T data, {
  3. Map<String, String>? arguments,
  4. String? correlationId,
})

Sends an event on an exact E key according to dispatch.

Implementation

bool fire<T>(EventKey<T> key, T data,
    {Map<String, String>? arguments, String? correlationId}) {
  _checkOpen();
  final dto = EventDTO<T>.withKey(key, data,
      arguments: arguments, correlationId: correlationId);
  _counters.fired++;

  if (dispatch == DispatchStrategy.broadcast) {
    var accepted = false;
    var delivered = false;
    for (final slot in _slots) {
      final bus = slot.bus;
      if (!slot.ready || bus == null) continue;
      delivered = true;
      accepted = _fireKeyOn<T>(
              slot, bus, key, data, arguments, correlationId) ||
          accepted;
    }
    if (!delivered) _counters.dropped++;
    return accepted;
  }

  final slot = _select(dto);
  return _fireKeyOnSelected<T>(slot, key, data, arguments, correlationId);
}