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(
(() => {
const fn = () => {};
subscribe(name, fn);
unsubscribe(name, fn);
return ch.hasSubscribers;
})(),
);
Sample output
false
