tracingChannel.hasSubscribers


稳定性: 1 - 实验性的

¥Stability: 1 - Experimental

  • 返回:<boolean> 如果任何单个通道有订阅者,则为 true,如果没有,则为 false

    ¥Returns: <boolean> true if any of the individual channels has a subscriber, false if not.

这是一个在 TracingChannel 实例上可用的辅助方法,用于检查 TracingChannel 通道 是否有任何订阅者。如果其中任何一个至少有一个订阅者,则返回 true,否则返回 false

¥This is a helper method available on a TracingChannel instance to check if any of the TracingChannel Channels have subscribers. A true is returned if any of them have at least one subscriber, a false is returned otherwise.

import diagnostics_channel from 'node:diagnostics_channel';

const channels = diagnostics_channel.tracingChannel('my-channel');

if (channels.hasSubscribers) {
  // Do something
}const diagnostics_channel = require('node:diagnostics_channel');

const channels = diagnostics_channel.tracingChannel('my-channel');

if (channels.hasSubscribers) {
  // Do something
}