I mean to say that a plugin or dependency injection of some kind be able to do something before the main process does anything.
On Tuesday, July 31, 2012 11:22:23 AM UTC-5, Dominic wrote: > > I don't quite understand the intension of the code you posted. > > do you mean to be able to have methods that you can add plugins to > that get called > before or after a main process does something? so that you can do > extra stuff when an event occurs? or do you mean to delay an event? > > On Wed, Aug 1, 2012 at 4:02 AM, Bradley Meck <[email protected]> > wrote: > > 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 > -- 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
