Open this example in the interactive library
Source code
import { channel, subscribe, unsubscribe } from "node:diagnostics_channel";
const name = "helpers:sample";
const ch = channel(name);
console.log(
(() => {
let key;
ch.subscribe((v, n) => (key = n));
ch.publish(1);
return key;
})(),
);
Sample output
helpers:sample
