1.0.1 • Published 7 years ago

await-emitter v1.0.1

Weekly downloads
118
License
MIT
Repository
github
Last release
7 years ago

await-emitter

add finish method on node EventEmitter for waiting all aync listeners to finish.

npm install await-emitter

Usage

Create a emitter instance and put it in the context or inject into modules used it.

import Emitter from 'await-emitter'

const emitter = new Emitter()

Use emitter.finish to emit an event, you can waiting all listeners finish their work. Then do the next action.

await emitter.finish('flushCache')
await emitter.finish('saveData')
emitter.emit('saveDone')