once abstract method

void once(
  1. String event,
  2. EventListener listener, {
  3. EventPriority priority = EventPriority.normal,
  4. Object? subscriber,
})

Registers a one-time listener for a specific event.

This is a convenience method equivalent to on with once: true. The listener is automatically removed after the first emission.

  • event: The name of the event.
  • listener: The function to call once.
  • priority: Execution priority.
  • subscriber: Optional subscriber association.

Example:

events.once('app.startup', initializeApp);

Implementation

void once(
  String event,
  EventListener listener, {
  EventPriority priority = EventPriority.normal,
  Object? subscriber,
});