https://github.com/gemini-testing/qemitter
EventEmitter, allowing to return promise from handlers
https://github.com/gemini-testing/qemitter
Last synced: 4 months ago
JSON representation
EventEmitter, allowing to return promise from handlers
- Host: GitHub
- URL: https://github.com/gemini-testing/qemitter
- Owner: gemini-testing
- License: mit
- Created: 2015-04-17T14:47:36.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2017-02-13T10:16:52.000Z (over 8 years ago)
- Last Synced: 2025-02-04T20:05:50.636Z (5 months ago)
- Language: JavaScript
- Size: 7.81 KB
- Stars: 1
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# QEmitter
Node.js event emitter with promises support.
Node.js builtin `EventEmmiter` class executes all handlers synchronously without
waiting for completion of any async operations that may happen inside.`QEmitter` is the subclass of `EventEmmiter` which adds ability to return a
promise from event handler and wait until it resolved. Just use `emitAndWait`
instead of `emit`:```javascript
var emitter = new QEmitter();
emitter.on('event', function() {
return Q.delay(1000);
});emmiter.emitAndWait('event')
.then(function() {
console.log('All handlers finished');
});
````emitAndWait` returns [`Q`](https://github.com/kriskowal/q) promise.
## utils
### passthroughEvent(from, to, event)
Passes event from `from` to `to`.
`event` can be an array of events.