I'm trying to understand how objects become event emitters. The documentation has something similar to the following code:
var EventEmitter = require('events').EventEmitter;
function Job(){
EventEmitter.call(this);
}
I'm unclear what the call function is doing here, apparently calling EventEmitter's constructor?
> var j = new Job()
undefined
> j.emit('test')
TypeError: Object #<Job> has no method 'emit'
After setting the prototype via Job.prototype = new EventEmitter;
seems to work as expected.