Created
March 20, 2015 21:29
-
-
Save jehoshua02/b9f788d5bd5da531b594 to your computer and use it in GitHub Desktop.
Do something after some condition is true ...
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
var after = function after(check, action, interval, limit) { | |
interval = interval || 0; | |
limit = limit === undefined ? 10 : limit; | |
if (check()) { | |
action(); | |
} else if (limit > 1) { | |
setTimeout(function () { | |
after(check, action, interval, --limit); | |
}, interval); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment