Skip to content

Instantly share code, notes, and snippets.

@ondrek
Last active July 3, 2023 21:14
Show Gist options
  • Save ondrek/9468784 to your computer and use it in GitHub Desktop.
Save ondrek/9468784 to your computer and use it in GitHub Desktop.
Node.js Boilerplate for prototype-based class with events-functionality
var events = require("events");
var Scanner = function() {
events.EventEmitter.call(this);
this.on("after1000", function(){
console.log("one");
});
this.on("after2000", function(){
console.log("two");
});
this.test();
};
require("util").inherits(CreateBuildDirectory, events.EventEmitter);
Scanner.prototype.test = function(){
setTimeout(function(){
that.emit("after1000", this);
}, 1000);
setTimeout(function(){
that.emit("after2000", this);
}, 2000);
};
new Scanner();
@ondrek
Copy link
Author

ondrek commented Mar 12, 2014

aka ~ how to work with callbacks in nodejs

@ondrek
Copy link
Author

ondrek commented Mar 12, 2014

currently implemented in vs-profesori and downpress repositories ;-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment