setHandler<T> method
void
setHandler<T>({})
override
Sets a handler for a specific topic. If an EventNode already exists for that topic, it updates the handler. Otherwise, it creates a new EventNode with the handler and initial data.
Implementation
@override
void setHandler<T>({T? initalData, String? path, String? target, required Handler<T> handler}) {
var t = Topic.create<T>(path: path, target: target);
var node = _eventsMap[t];
if (node != null && node is EventNode<T>) {
node.handler = handler;
} else {
_eventsMap[t] = EventNode<T>(handler: handler, lastData: initalData);
}
}