on<P extends dynamic> method

void on<P extends dynamic>(
  1. Enum eventName,
  2. CallbackEvent<T, P> callback
)

Puts on to listen eventName event.

When the event is emitted, the callback is called.

Implementation

void on<P extends dynamic>(Enum eventName, CallbackEvent<T, P> callback) {
  _events[_instanceReceived] ??= HashMap();
  _events[_instanceReceived]?[eventName] ??= HashSet();
  _events[_instanceReceived]?[eventName]?.add(callback);
}