var Util = require('util');
var EventEmitter = require('events').EventEmitter;
function myfunc(cb) {
EventEmitter.call(this);
this.emit('end');
cb();
}
Util.inherits(myfunc, EventEmitter);
var go = new myfunc(function() {
console.log("Got CB");
});
go.on('end', function() {
console.log("END by emit");
});
Expected output:
END by emit
Got CB
Actual output:
Got CB
var Util = require('util');
var EventEmitter = require('events').EventEmitter;
function myfunc(cb) {
EventEmitter.call(this);
self = this;
setTimeout((function() { self.emit('end'); }), 2000);
cb();
}
Util.inherits(myfunc, EventEmitter);
var go = new myfunc(function() {
console.log("Got CB");
});
go.on('end', function() {
console.log("END by emit");
});
Expected output:
Got CB
END by emit
Actual output:
Got CB
END by emit