open-wa
DocsAPI reference

@open-wa/hyperemitter

HyperEmitter: high-performance, schema-driven event emitter for the open-wa v5 stack.

@open-wa/hyperemitter

@open-wa/hyperemitter is a typed event emitter used by Open-WA packages. It supports exact event names, + and # wildcard subscriptions, one-time listeners, catch-all listeners, and listener cleanup with an AbortSignal.

Use

import { HyperEmitter } from '@open-wa/hyperemitter';

type Events = {
  'message.received': { id: string; body: string };
  'session.state.changed': { state: string };
};

const events = new HyperEmitter<Events>();

events.on('message.received', (message) => {
  console.log(message.id, message.body);
});

events.emit('message.received', { id: 'message-id', body: 'Hello' });

The repository also contains a benchmark runner for comparing other emitter libraries. Its results are measurements from that runner, not a performance guarantee.

License

Apache-2.0

Was this helpful?

Your answer includes the page path and docs version.

On this page