@jorvel/event-bus
v0.2.0
Published
Typed pub/sub event bus for JORVEL micro-frontends with wildcard, replay, and cross-tab support.
Maintainers
Readme
@jorvel/event-bus
Typed pub/sub event bus for JORVEL micro-frontends. Provides:
EventBus<EventMap>withon,once,off,emit.onAny(handler)wildcard for logging / devtools.- Optional replay so late-mounting subscribers can receive the most recent event.
globalThis-pinned singleton (getGlobalBus()) safe under duplicate bundles.
Install
pnpm add @jorvel/event-busExample
import { getGlobalBus } from '@jorvel/event-bus';
import type { MfAppEvents } from '@jorvel/events';
const bus = getGlobalBus<MfAppEvents>();
bus.on('shell:ready', payload => console.log('shell ready', payload));
bus.emit('shell:ready', { ts: Date.now() });