Created
September 10, 2012 02:25
-
-
Save sagarsane/3688474 to your computer and use it in GitHub Desktop.
Self calling functions + setTimeout instead of setInterval
This file contains 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
/* | |
This is very useful and smoother (feels like at least) when you want to do something like live updates on the UI or something (thinking Windows 8 UI styling?) | |
*/ | |
(function better(){ | |
//logic here | |
setTimeout(better, 100); | |
})(); | |
/* | |
This will ensure that the function is called only after the logic executes (which can sometimes be a problem in setInterval | |
*/ | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment