on and once
Register persistent or one-shot subscribers. One-shot records are removed before invocation, including reentrant emits.
Read the API →Node · bundled + unbundled browser · synchronous
One small publish/subscribe class for Node.js, bundled browser applications, and unbundled native ESM—with predictable wildcard ordering, fluent methods, and no required build step.
npm install event-pubsubRelease status: 6.1.1 is the current npm and GitHub release.
The small surface
Registration and dispatch stay direct. The deeper documentation is split into focused pages so you can get an answer without crossing a wall of prose.
on and onceRegister persistent or one-shot subscribers. One-shot records are removed before invocation, including reentrant emits.
Read the API →emitRun wildcard subscribers first, then typed subscribers, synchronously and in registration order.
See patterns →off and resetRemove one function, one topic, wildcard subscribers, or the complete registry while keeping fluent chaining.
Understand lifecycle →The 6.1.1 source runs directly as native browser ESM. Put the map before the first module script and serve the installed files over HTTP(S).
<script type="importmap">
{"imports":{"event-pubsub":"./node_modules/event-pubsub/index.js","strong-type":"./node_modules/strong-type/index.js"}}
</script>
<script type="module">
import EventPubSub from 'event-pubsub';
const events = new EventPubSub();
events.on('ready', (payload) => {
console.log(payload);
});
events.emit('ready', { fast: true });
</script>If the app uses a strict CSP, authorize the inline import-map and module scripts with an allowed nonce or hash.
Quality is inspectable
The same shared suite runs in Node and real Chrome. Independent coverage reports, normalized results, package smoke tests, and execution-latency charts ship with the Pages deployment.