node.js - EventEmitter implementation that allows you to get the listeners' results? -


i realise nodejs has powerful eventemitter constructor allows emit events. however, eventemitter missing way event emitter see listeners returned.

this functionality after:

e = new fantasticeventemitter();  e.on( 'event1', function( param1, param2, cb ){   console.log("first listener called...")   cb( null, 10 ); });  e.on( 'event1', function( param2, param2, cb ){    console.log("ah, listener called!");    cb( null, 20 ); });  e.emit( 'event1', 'firstparameter', 'secondparameter', function( err, res ){   console.log("event emitted, res [ 10, 20]"); }); 

basically, want listeners able register, getting called when event fired up, and:

  • listeners passed callback parameter. callback "collect" results
  • emitters have callback, called result collections

is there library already, before reinvent wheel?

there no easy way it. allow asked for, wrote guthub module:

eventemittercollector.

enjoy...


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -