EventEmitter.emit that wraps event calls in a promise
EventEmitter.prototype.emit that wraps event calls in a promise.
$ npm install emit-then
emitThen to your emitter prototype(s):
httpserveremitThen = ;
EventEmitter.prototype to make it available on all emitters:
Traditional event handlers behave as usual:
Handlers can return promises:
Just like calling
emit, the return value or resolution of the promise is unused.
If a handler returns a rejected promise,
emitThen is immediately rejected with the error:
You can also reject
emitThen by throwing an error from a handler: