@smikhalevski/event-bus
v1.0.0
Published
Yet another event bus.
Downloads
237
Readme
event-bus
Yet another event bus. There are many like it, but this one is mine.
The most primitive implementation of a push-based event bus (pub/sub) that you can find.
npm install --save-prod @smikhalevski/event-bus
import {EventBus} from '@smikhalevski/event-bus';
interface IFooEvent {
foo: string;
}
const eventBus = new EventBus<IFooEvent>();
const unsubscribe = eventBus.subscribe((event) => console.log(event.foo));
eventBus.publish({foo: 'abc'}); // Outputs "abc" to console
unsubscribe();