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}) {
  if (isDisposed) {
    throw StateError('EventBusIsolate is disposed');
  }
  if (!_ready) {
    throw StateError(
        'EventBusIsolate is not initialized: await waitInit before fire');
  }
  final observing = _metricsEnabled;
  final started = observing ? DateTime.now().microsecondsSinceEpoch : 0;
  final accepted = _link.remoteInterest.hasListener(key.address.value) &&
      _link.fire(EventDTO<T>.withKey(key, data,
          arguments: arguments, correlationId: correlationId));
  if (observing) {
    metrics.recordFire(key.address.value,
        accepted: accepted,
        elapsedMicros: DateTime.now().microsecondsSinceEpoch - started);
  }
  return accepted;
}