Skip to content

Instantly share code, notes, and snippets.

@fabiomcosta
Created January 28, 2010 21:16
Show Gist options
  • Save fabiomcosta/289149 to your computer and use it in GitHub Desktop.
Save fabiomcosta/289149 to your computer and use it in GitHub Desktop.
/*
old delay function
delay: function(delay, bind, args){
return this.create({bind: bind, arguments: args, delay: delay})();
}
*/
// problem: the code above is done often
$clear(this.timer);
this.timer = this.fn.delay(100, bind, [args]);
/*
proposed
delay: function(delay, bind, args, clear){
if(clear) $clear(this.delayTimer);
this.delayTimer = this.create({bind: bind, arguments: args, delay: delay})();
return this.delayTimer;
}
*/
// you would just do
this.fn.delay(100, bind, [args], true);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment