boundedChannel.subscribe(handlers)
handlers<Object> 通道订阅者集合start<Function> 开始事件订阅者end<Function> 结束事件订阅者
订阅有界通道事件。这相当于对每个通道单独调用 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
},
});