off<T, P> method

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

Removes the callback of event.

Implementation

void off<T, P>(
  Object? instance,
  Enum eventName,
  CallbackEvent<T, P> callback,
) {
  _oneOff<T, P>(instance, eventName, callback);

  final _eventKey = _getEventKey(instance, eventName);

  if (!(_events[_eventKey]?.contains(callback) ?? false)) {
    return;
  }

  if (instance is ReactterNotifyManager) {
    instance._removeListener();
  }

  _events[_eventKey]?.remove(callback);

  if (_events[_eventKey]?.isEmpty ?? false) {
    _events.remove(_eventKey);
  }
}