in src/diagnostic-channel/src/channel.ts [60:83]
public publish<T>(name: string, event: T): void {
if (this.currentlyPublishing) {
return; // Avoid reentrancy
}
const listeners = this.subscribers[name];
// Note: Listeners called synchronously to preserve context
if (listeners) {
const standardEvent = {
timestamp: Date.now(),
data: event,
};
this.currentlyPublishing = true;
listeners.forEach(({listener, filter}) => {
try {
if (filter && filter(true)) {
listener(standardEvent);
}
} catch (e) {
// Subscriber threw an error
}
});
this.currentlyPublishing = false;
}
}