0.7.1 • Published 2 years ago
@nbottarini/eventbus v0.7.1
EventBus
Simple and lightweight EventBus javascript implementation
Installation
Npm:
$ npm install --save @nbottarini/eventbusYarn:
$ yarn add @nbottarini/eventbusUsage
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 {
}