Created
April 11, 2015 03:00
-
-
Save dustintheweb/7f0de005c5f7dc887929 to your computer and use it in GitHub Desktop.
A self clearing setInterval with a callback
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 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