channel.unsubscribe(onMessage)
稳定性: 0 - 已弃用:使用
diagnostics_channel.unsubscribe(name, onMessage)
¥Stability: 0 - Deprecated: Use diagnostics_channel.unsubscribe(name, onMessage)
-
onMessage
<Function> 要删除的先前订阅的处理程序¥
onMessage
<Function> The previous subscribed handler to remove -
返回:<boolean> 如果找到处理程序则为
true
,否则为false
。¥Returns: <boolean>
true
if the handler was found,false
otherwise.
删除以前使用 channel.subscribe(onMessage)
注册到此通道的消息处理程序。
¥Remove a message handler previously registered to this channel with
channel.subscribe(onMessage)
.
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);
const diagnostics_channel = require('node:diagnostics_channel');
const channel = diagnostics_channel.channel('my-channel');
function onMessage(message, name) {
// Received data
}
channel.subscribe(onMessage);
channel.unsubscribe(onMessage);