fire<T> method

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

Publishes data on an exact typed key.

Implementation

@override
bool fire<T>(EventKey<T> key, T data,
    {Map<String, String>? arguments, String? correlationId}) {
  _checkNotDisposed();
  final observing = _metricsEnabled;
  final started = observing ? DateTime.now().microsecondsSinceEpoch : 0;
  final dto = EventDTO<T>.withKey(key, data,
      arguments: arguments, correlationId: correlationId);
  // A model or transport bus may create the exact node for this key.
  _sendNode<T>(key);
  final matched = _dispatchToListeners(dto);
  // A model bus accepted the value even when nobody is listening. A handler
  // subscription alone does not count for fire (D14).
  final accepted = matched ||
      (isModelBus && _eventsMap[key.address]?[key.type] != null);
  _addAllEvent(dto, accepted);
  if (observing) {
    metrics.recordFire(key.address.value,
        accepted: accepted,
        elapsedMicros: DateTime.now().microsecondsSinceEpoch - started);
  }
  return accepted;
}