Skip to main content
Channel.prototype.subscribe - node__diagnostics_channel.d.ts - Node documentation
method Channel.prototype.subscribe

Usage in Deno

```typescript import { Channel } from "node:node__diagnostics_channel.d.ts"; ```
Channel.prototype.subscribe(onMessage: ChannelListener): void
Deprecated
Since v18.7.0,v16.17.0 - Use onMessage)
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'`. ```js import diagnostics_channel from 'node:diagnostics_channel'; const channel = diagnostics_channel.channel('my-channel'); channel.subscribe((message, name) => { // Received data }); ```

Parameters

onMessage: ChannelListener
The handler to receive channel messages

Return Type

void