addEventListener method

void addEventListener(
  1. NawahListenerKey event,
  2. dynamic filter,
  3. dynamic callable, {
  4. bool once = false,
  5. String? tag,
})

Implementation

void addEventListener(NawahListenerKey event, filter, callable, {bool once = false, String? tag}) {
  Map<NawahListenerKey, dynamic> listenerObjects = {
    NawahListenerKey.message: NawahMessageListener(
      filter: filter,
      callable: callable,
      once: once,
      tag: tag,
    ),
    NawahListenerKey.connStateChange: NawahConnStateListener(
      filter: filter,
      callable: callable,
      once: once,
      tag: tag,
    ),
    NawahListenerKey.authStateChange: NawahAuthStateListener(
      filter: filter,
      callable: callable,
      once: once,
      tag: tag,
    ),
  };

  _listeners[event]!.add(listenerObjects[event]);
}