Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/dgeibi/event-emitter

a functional event emitter
https://github.com/dgeibi/event-emitter

eventemitter

Last synced: 1 day ago
JSON representation

a functional event emitter

Awesome Lists containing this project

README

        

# uemitter

- API like [Node's EventEmitter](https://nodejs.org/api/events.html#events_class_eventemitter)
- support `emitAsync`
- methods don't rely on `this`

## Install

```
$ npm install uemitter
```

## Usage

``` js
import Emitter from 'uemitter';
// or // const Emitter = require('uemitter');

const emitter = Emitter();

// listen to an event
emitter.once('foo', async () => {
const data = await fetch('example.com/foo.json').then(res => res.json());
// do something with data
});

(async () => {
// emit an event
await emitter.emitAsync('foo');
})();
```