Last active
August 29, 2015 14:13
-
-
Save ray-peters/1890c61cb83f77fd47e0 to your computer and use it in GitHub Desktop.
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
| // This design pattern allows you to wait without hogging up resources like | |
| // setInterval, nor giving you an errand like clearInterval() after it's done | |
| function doStuff(){ | |
| if ( !something.isReady ) { | |
| setTimeout( doStuff, 50 ); | |
| return; | |
| } | |
| // Actually do the stuff you need to wait for | |
| } | |
| setTimeout( doStuff, 1000 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment