Skip to content

nbottarini/eventbus-js

Repository files navigation

npm License: MIT CI Status

EventBus

Simple Typescript and Javascript event bus

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 {
}

About

Simple Typescript and Javascript event bus

Resources

License

Stars

Watchers

Forks

Packages

No packages published