one<P> method

void one<P>(
  1. Enum eventName,
  2. CallbackEvent<T, P> callback
)

Puts on to listen eventName event only once.

When the event is emitted, the callback is called and after removes eventName event.

Implementation

void one<P>(Enum eventName, CallbackEvent<T, P> callback) {
  void _oneCallback(inst, param) {
    callback(inst, param);

    off(eventName, callback);
    off(eventName, _oneCallback);
  }

  on<P>(eventName, _oneCallback);
}