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
},
});