boundedChannel.subscribe(handlers)


订阅有界通道事件。这相当于对每个通道单独调用 channel.subscribe(onMessage)

🌐 Subscribe to the bounded channel events. This is equivalent to calling channel.subscribe(onMessage) on each channel individually.

import { boundedChannel } from 'node:diagnostics_channel';

const wc = boundedChannel('my-operation');

wc.subscribe({
  start(message) {
    // Handle start
  },
  end(message) {
    // Handle end
  },
});const { boundedChannel } = require('node:diagnostics_channel');

const wc = boundedChannel('my-operation');

wc.subscribe({
  start(message) {
    // Handle start
  },
  end(message) {
    // Handle end
  },
});