boundedChannel.hasSubscribers
- 返回:<boolean>
true如果任意一个单独的通道有订阅者,false如果没有。
检查 start 或 end 通道是否有订阅者。
🌐 Check if any of the start or end channels have subscribers.
import { boundedChannel } from 'node:diagnostics_channel';
const wc = boundedChannel('my-operation');
if (wc.hasSubscribers) {
// There are subscribers, perform traced operation
}const { boundedChannel } = require('node:diagnostics_channel');
const wc = boundedChannel('my-operation');
if (wc.hasSubscribers) {
// There are subscribers, perform traced operation
}