tracingChannel.unsubscribe(subscribers)
稳定性: 1 - 实验性
subscribers<Object> TracingChannel 通道 个订阅者的集合start<Function>start活动 订阅者end<Function>end活动 订阅者asyncStart<Function>asyncStart活动 订阅者asyncEnd<Function>asyncEnd活动 订阅者error<Function>error活动 订阅者
- 返回:<boolean>
true表示所有处理程序都已成功取消订阅,false表示否则。
帮助取消订阅一组函数对应的通道。这与对每个通道单独调用 channel.unsubscribe(onMessage) 相同。
🌐 Helper to unsubscribe a collection of functions from the corresponding channels.
This is the same as calling channel.unsubscribe(onMessage) on each channel
individually.
import diagnostics_channel from 'node:diagnostics_channel';
const channels = diagnostics_channel.tracingChannel('my-channel');
channels.unsubscribe({
start(message) {
// Handle start message
},
end(message) {
// Handle end message
},
asyncStart(message) {
// Handle asyncStart message
},
asyncEnd(message) {
// Handle asyncEnd message
},
error(message) {
// Handle error message
},
});const diagnostics_channel = require('node:diagnostics_channel');
const channels = diagnostics_channel.tracingChannel('my-channel');
channels.unsubscribe({
start(message) {
// Handle start message
},
end(message) {
// Handle end message
},
asyncStart(message) {
// Handle asyncStart message
},
asyncEnd(message) {
// Handle asyncEnd message
},
error(message) {
// Handle error message
},
});