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

Usage in Deno

```typescript import { Channel } from "node:node__diagnostics_channel.d.ts"; ```
Channel.prototype.unsubscribe(onMessage: ChannelListener): void
Deprecated
Since v18.7.0,v16.17.0 - Use onMessage)
Remove a message handler previously registered to this channel with `channel.subscribe(onMessage)`. ```js import diagnostics_channel from 'node:diagnostics_channel'; const channel = diagnostics_channel.channel('my-channel'); function onMessage(message, name) { // Received data } channel.subscribe(onMessage); channel.unsubscribe(onMessage); ```

Parameters

onMessage: ChannelListener
The previous subscribed handler to remove

Return Type

void
`true` if the handler was found, `false` otherwise.