Trying to make an object emitting and receiving events:
var events = require('events'),
util = require('util');
function Obj(){
events.EventEmitter.call( this ); // what does this line?
}
util.inherits( Obj, events.EventEmitter );
var o = new Obj(),
a = new Obj();
a.on('some', function () {
console.log('a => some-thing happened');
});
o.on('some', function () {
console.log('o => some-thing happened');
});
o.emit('some');
- having a response
o => some-thing happened
only from the same object but not another. Why? And how to make them both to listensome
event? - What
events.EventEmitter.call( this );
line does? It doesnt make any difference to result. Taken from http://nodejs.org/api/util.html#util_util_inherits_constructor_superconstructor