@nbottarini/eventbus
v0.7.1
Published
Simple and lightweight EventBus implementation
Downloads
168
Readme
EventBus
Simple and lightweight EventBus javascript implementation
Installation
Npm:
$ npm install --save @nbottarini/eventbus
Yarn:
$ yarn add @nbottarini/eventbus
Usage
class Producer {
constructor(private eventBus: EventBus) {}
async doSomething() {
await eventBus.post(new SampleEvent())
}
}
class Consumer {
constructor(private eventBus: EventBus) {
this.eventBus.subscribe(this, SampleEvent, this.onSampleEvent)
}
onSampleEvent(event: SampleEvent) {
// Do Something
}
}
class SampleEvent extends EventInterface {
}