send<T> method
Sends an event to the bus. If a handler exists for the topic, it will be called. Returns a Future that completes with the result if EventDTO.completer was called by the handler. If no handler exists, returns null.
Implementation
@override
Future? send<T>(T data, {String? path, String? fragment, String? target, Map<String, String>? arguments}) async {
var dto =
EventDTO<T>(data, path: path, fragment: fragment, arguments: arguments, target: target, completer: Completer());
var node = _eventsMap[dto.topic];
if (node != null && node is EventNode<T>) {
node.send(dto);
_allEventStream.add((dto, true));
return dto.completer?.future;
} else if (isModelBus) {
_eventsMap[dto.topic] = EventNode<T>();
_eventsMap[dto.topic]!.send(dto);
_allEventStream.add((dto, true));
return dto.completer?.future;
}
_allEventStream.add((dto, false));
return null;
}