promisify-event-bind
v0.1.0
Published
Bind [promisify-event] to all EventEmitter's `.on` methods
Downloads
6
Maintainers
Readme
promisify-event-bind
Bind promisify-event to all EventEmitter's .on
methods
Install
npm install promisify-event-bind
Usage
const promisifyAll = require('promisify-event-bind');
promisifyAll(server);
server.on('listening').then(() => {
// ...
})
Note that since this is a promise it can only be resolved once (which is what it does).
It's good for one-off events:
const socket = await io.on('connection');
Not for events that'll fire multiple times with possibly different values:
socket.on('message', data => {...});