Skip to content

Instantly share code, notes, and snippets.

@MiguelDebruyne
Created May 15, 2014 09:55
Show Gist options
  • Save MiguelDebruyne/e5ff83e9e29b6c8ee53e to your computer and use it in GitHub Desktop.
Save MiguelDebruyne/e5ff83e9e29b6c8ee53e to your computer and use it in GitHub Desktop.
JavaScript: Interval Method
function Interval (fn, time)
{
var timer = false;
this.start = function () {
if (!this.isRunning()) {
timer = setInterval(fn, time);
}
};
this.stop = function () {
clearInterval(timer);
timer = false;
};
this.isRunning = function () {
return timer !== false;
};
// var blaInterval = new Interval(functionName, time);
// blaInterval.start();
// blaInterval.stop();
// if (blaInterval.isRunning())
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment