Skip to content

Instantly share code, notes, and snippets.

@ybouhjira
Created January 29, 2014 03:04
Show Gist options
  • Save ybouhjira/8681050 to your computer and use it in GitHub Desktop.
Save ybouhjira/8681050 to your computer and use it in GitHub Desktop.
node.js Timer module
var util = require('util');
var EventEmitter = require('events').EventEmitter;
// EMitter
function Timer(interval)
{
var that = this;
var _interval = interval;
this.getInterval = function(){
return _interval;
}
this.setInterval = function(interval){
_interval = interval;
}
setInterval(function(){
that.emit('tick');
}, _interval);
}
util.inherits(Timer, EventEmitter);
module.exports = Timer;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment