@vielzeug/herald
v26.10.18
Published
Typed synchronous event bus with wildcard subscriptions, one-shot waits, and lifecycle tracing
Readme
@vielzeug/herald
Typed synchronous event bus with wildcard subscriptions, one-shot waits, and lifecycle tracing
Installation
pnpm add @vielzeug/herald
npm install @vielzeug/herald
yarn add @vielzeug/heraldQuick Start
import { createBus } from '@vielzeug/herald';
interface AppEvents {
'user:login': { userId: string };
'user:logout': void;
}
using bus = createBus<AppEvents>({ name: 'app' });
const stop = bus.on('user:login', ({ userId }) => console.log(userId));
bus.emit('user:login', { userId: '42' });
bus.emit('user:logout');
stop();Documentation
License
MIT © Helmuth Saatkamp: part of the Vielzeug monorepo.
