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?
Comments
Post a Comment