@vielzeug/herald
v2.3.0
Published
Typed event bus — pub/sub with namespaces, wildcards, and once-listeners
Readme
@vielzeug/herald
Zero-dependency typed event bus with subscribe/emit, wait(), async streams, AbortSignal support, bus piping, and test helpers.
Package: @vielzeug/herald · Category: Events
Key exports: createBus, pipeEvents, createTestBus
When to use: Decoupled inter-module communication via a typed event bus. Supports subscribe/emit, one-time await, async iteration, event piping, and AbortSignal lifecycle management.
Related: @vielzeug/ripple · @vielzeug/wayfinder · @vielzeug/familiar
@vielzeug/herald is part of Vielzeug and ships as a zero-dependency TypeScript package with ESM+CJS output.
Installation
pnpm add @vielzeug/herald
npm install @vielzeug/herald
yarn add @vielzeug/heraldQuick Start
import { createBus, pipeEvents } from '@vielzeug/herald';
interface AppEvents {
'user:login': { email: string; userId: string };
'user:logout': void;
}
const bus = createBus<AppEvents>();
const auditBus = createBus<AppEvents>();
const stop = bus.on('user:login', ({ userId }) => console.log('Logged in:', userId));
const stopPipe = pipeEvents(bus, auditBus, ['user:login', 'user:logout']);
bus.emit('user:login', { email: '[email protected]', userId: '42' });
bus.emit('user:logout');
stopPipe();
stop();
bus.dispose();
auditBus.dispose();Documentation
License
MIT © Helmuth Saatkamp — part of the Vielzeug monorepo.
