on<T, P> method

void on<T, P>(
  1. Object? instance,
  2. Enum eventName,
  3. CallbackEvent<T, P> callback
)

Puts on to listen eventName event.

When the event is emitted(by emit), the callback is called.

Implementation

void on<T, P>(
  Object? instance,
  Enum eventName,
  CallbackEvent<T, P> callback,
) {
  var notifier = ReactterNotifier(instance, eventName);
  notifier = _notifiers.lookup(notifier) ?? notifier;
  notifier.addListener(callback);
  _notifiers.add(notifier);
}