call<T extends Event> method

bool call<T extends Event>(
  1. T event
)

Checks if the listener matches the event. If the event is valid, the callback will be called.

This method will not call the callback if the listener is canceled.

Returns true if the callback was satisfied. Listeners that don't match the event count as satisfied.

Implementation

bool call<T extends Event>(T event) {
  if (!canceled && validate(event)) {
    final data =
        (event.data is CallbackDataT ? event.data : event) as CallbackDataT;
    final satisfied = callback(data);
    if (once) cancel();

    onCall?.call(data);

    if (satisfied is bool) return satisfied;
    return true;
  }
  return false;
}