Dev Helpers
← Back

Wrap work in a channel store

Wrap work in a channel store using Node.js.

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 called = false;
    ch.runStores({ id: 2 }, () => (called = true));
    return called;
  })(),
);

Sample output

true