Skip to content

Instantly share code, notes, and snippets.

@assertchris
Created June 1, 2010 12:26
Show Gist options
  • Save assertchris/420885 to your computer and use it in GitHub Desktop.
Save assertchris/420885 to your computer and use it in GitHub Desktop.
JavaScript Function.prototype.when method
Function.prototype.when = function(check, interval, bind)
{
var bind = bind || this,
timer = setInterval(function() {
if (check.apply(bind))
{
clearInterval(timer);
this.apply(bind);
}
}, (interval || 100));
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment