@nbottarini/eventbus
TypeScript icon, indicating that this package has built-in type declarations

0.7.1 • Public • Published

npm License: MIT CI Status

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

Readme

Keywords

Package Sidebar

Install

npm i @nbottarini/eventbus

Weekly Downloads

27

Version

0.7.1

License

MIT

Unpacked Size

13.6 kB

Total Files

8

Last publish

Collaborators

  • nbottarini