send<T> method

void send<T>(
  1. NUIBusEventData<T> payload, {
  2. String? channel,
})

Implementation

void send<T>(NUIBusEventData<T> payload, {String? channel}) {
  final targetChannel = channel ?? _GLOBAL_CHANNEL;
  final observers = _observers[targetChannel] ?? [];
  final observersInvoke = _observersInvoke[targetChannel] ?? Map();
  observers.forEach((NUIBusEventListener obj){
    // if(obj is NUIBusEventListener<T>) {
    try {
      obj.onBusEventReceived(payload);
    } catch(e){
      logNUI(_MODULE, "Exception encountered on sending bus event with error : $e");
    }
    // }
  });

  for(var func in observersInvoke.values){
    try {
      func(payload);
    }catch(e){
      logNUI(_MODULE, "Exception encountered on sending bus event with error : $e");
    }
  }
}