Created
May 12, 2011 15:31
-
-
Save steadicat/968753 to your computer and use it in GitHub Desktop.
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
function debounce(f, delay) { | |
var timeout; | |
return function() { | |
if (f.active) return WARNING('Refresh throttled: operation already started less than 5 seconds ago.'); | |
f.active = true; | |
f.call(this, function() { | |
if (delay) { | |
if (timeout) clearTimeout(timeout); | |
timeout = setTimeout(function() { f.active = false }, delay); | |
} else { | |
f.active = false; | |
} | |
}); | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment