Skip to main content
subscribe - node__diagnostics_channel.d.ts - Node documentation
function subscribe

Usage in Deno

```typescript import { subscribe } from "node:node__diagnostics_channel.d.ts"; ```
subscribe(
name: string | symbol,
onMessage: ChannelListener,
): void
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'; diagnostics_channel.subscribe('my-channel', (message, name) => { // Received data }); ```

Parameters

name: string | symbol
The channel name
onMessage: ChannelListener
The handler to receive channel messages

Return Type

void