once method

void once(
  1. String event,
  2. Function handler
)

This function binds the handler as listener to the first occurrence of the event. When handler is called once, it is removed.

Implementation

void once(String event, Function handler) {
  if (singleEvents.containsKey(event)) {
    singleEvents[event]!.add(handler);
  } else {
    singleEvents[event] = [handler];
  }
}