1.0.0 • Published 10 years ago

then-events v1.0.0

Weekly downloads
2
License
MIT
Repository
github
Last release
10 years ago

Node Asynchronous EventEmitter

This is an EventEmitter for NodeJS which works with event listeners which have an awaitable return type. The emit-function is tuned to return a promise which is resolved as soon as all callbacks have finished.

npm i --save then-events
import { AsyncEventEmitter } from "then-events"

const emitter = new AsyncEventEmitter()

emitter.on('foo', () => {
  return new Promise(accept => {
    setTimeout(accept, 100)
  })
})

emitter.emit('foo').then(() => {
  console.log('it is done.')
})