Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/varharrie/event-bus-station

:bus: Simple event bus.
https://github.com/varharrie/event-bus-station

Last synced: about 5 hours ago
JSON representation

:bus: Simple event bus.

Awesome Lists containing this project

README

        

# event-bus-station

Simple event bus.

## Usage

```typescript
import {EventBus} from 'event-bus-station'

const bus = new EventBus()

const callback = function (data: any) {
console.log(data)
}

bus.once('mount', callback) // single use

bus.on('update', callback)

bus.emit('mount', {a: '1'})

bus.emit('update', {b: '2'})

bus.off('update', callback)

bus.off('update') // remove all listener on 'update'

```