Created
March 28, 2013 14:45
-
-
Save justinobney/5263690 to your computer and use it in GitHub Desktop.
A more expressive setTimeout
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
| $.wait = function(time) { | |
| return $.Deferred(function(dfd) { | |
| setTimeout(dfd.resolve, time); | |
| }).promise(); | |
| }; | |
| /* | |
| ---------------------------- | |
| Use Case | |
| ---------------------------- | |
| $.wait(1000).then(function(){ | |
| // Do some work... | |
| }); | |
| ---------------------------- | |
| */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment