addListener method

  1. @mustCallSuper
void addListener(
  1. String eventName,
  2. Function callback, {
  3. bool once = false,
})

Implementation

@mustCallSuper
void addListener(String eventName, Function callback, {bool once = false}) {
  assert(callback != null);
  assert(eventName != null);
  assert(eventName.isNotEmpty);

  if (!_events.containsKey(eventName)) {
    _events[eventName] = <_KuzzleListener>[];
  }

  if (!_exist(eventName, callback)) {
    _events[eventName]!.add(_KuzzleListener(callback, once: once));
  }
}