1.0.0 • Published 2 years ago

@smikhalevski/event-bus v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

event-bus build

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();