Skip to main content

subscribe

method Channel.prototype.subscribe
Jump to headingChannel.prototype.subscribe(onMessage: ChannelListener): void
Deprecated

Register a message handler to subscribe to this channel. This message handler will be run synchronously whenever a message is published to the channel. Any errors thrown in the message handler will trigger an 'uncaughtException'.

import diagnostics_channel from 'node:diagnostics_channel';

const channel = diagnostics_channel.channel('my-channel');

channel.subscribe((message, name) => {
  // Received data
});

Parameters Jump to heading

The handler to receive channel messages

Return Type Jump to heading

void
Back to top