Wondering what everyone is doing for hookable events these days. I am
looking to use something that lets me do similar to emitHook(ee, event,
arg1, after(err)), I am wondering what other people are doing, or if they
are using something instead of event emitters to share state for hookable
events. I could use my own implementation but would rather follow an
established pattern if there is any.
```
function emitHook(ee, event, /*...,*/ callback) {
var args = [].slice.call(arguments, 1, -1);
var defers = 0;
function defer(hook) {
defers++;
hook(finish);
}
function finish(err) {
if (err) {
defers = 0;
}
defers--;
if (defers === 0) {
callback(err);
}
}
if (defers === 0) {
callback();
}
return ee.emit.apply(ee, args.concat(defer));
}
```
--
Job Board: http://jobs.nodejs.org/
Posting guidelines:
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en