Skip to content

Instantly share code, notes, and snippets.

@jehoshua02
Created March 20, 2015 21:29
Show Gist options
  • Save jehoshua02/b9f788d5bd5da531b594 to your computer and use it in GitHub Desktop.
Save jehoshua02/b9f788d5bd5da531b594 to your computer and use it in GitHub Desktop.
Do something after some condition is true ...
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