Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dustintheweb/7f0de005c5f7dc887929 to your computer and use it in GitHub Desktop.
Save dustintheweb/7f0de005c5f7dc887929 to your computer and use it in GitHub Desktop.
A self clearing setInterval with a callback
var i = 0;
var timer = setInterval(function(){
// stuff
if(i === 5) {
clearInterval(timer);
console.log('callback'); // callback after some time
}
}, 200);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment