Last active
August 29, 2015 14:22
-
-
Save toanalien/89b5d725e1d6e86df0b5 to your computer and use it in GitHub Desktop.
Emitting Events
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var util = require('util'), | |
EventEmitter = require('events').EventEmitter; | |
var Ticker = function(){ | |
var self = this; | |
setInterval(function(){ | |
self.emit('tick'); | |
},1000); | |
}; | |
util.inherits(Ticker,EventEmitter); | |
var ticker = new Ticker(); | |
ticker.on("tick", function(){ | |
console.log("tick"); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment