Skip to content

Instantly share code, notes, and snippets.

Created July 4, 2015 08:13
What would you like to do?
Node.js EventEmitter example
var EventEmitter = require("events").EventEmitter;
var door = new EventEmitter();
door.on("doorbell", function(seconds){
console.log("Doorbell rang for " + seconds + " seconds.");
/* In another file, for example... */
function ring(seconds) {
door.emit("doorbell", seconds);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment