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

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.7.1
    25
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 0.7.1
    25
  • 0.7.0
    0
  • 0.6.2
    0
  • 0.6.1
    0
  • 0.6.0
    0

Package Sidebar

Install

npm i @nbottarini/eventbus

Weekly Downloads

25

Version

0.7.1

License

MIT

Unpacked Size

13.6 kB

Total Files

8

Last publish

Collaborators

  • nbottarini