onApplicationEvent method

  1. @override
void onApplicationEvent(
  1. Object event
)
override

Handles an event that supportsEvent accepted.

An error thrown here goes to the multicaster's error handler, or to the publisher when there is none.

Implementation

@override
void onApplicationEvent(Object event) {
  if (event is! AvailabilityChangeEvent<AvailabilityState>) {
    return;
  }
  // Keyed by the state's enum, whatever type argument the event has.
  final type = switch (event.state) {
    LivenessState() => LivenessState,
    ReadinessState() => ReadinessState,
    final other => other.runtimeType,
  };
  final last = _events[type];
  _events[type] = event;
  _log.debug(
    () =>
        'Application availability state $type changed'
        '${last == null ? '' : ' from ${_name(last.state)}'} to '
        '${_name(event.state)}',
  );
}