Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Magic-ness to only run the save callback after no saves have been issued for a while
- var executeAfter = function(f, ms)
- {
- var timer;
- var wrapper = function()
- {
- var passedArguments = arguments;
- if (timer)
- {
- window.clearTimeout(timer);
- timer = null;
- }
- timer = window.setTimeout(function() {
- f.apply(window, passedArguments);
- }, ms);
- }
- return wrapper;
- };
- saveCallback = executeAfter(saveCallback, 500);
- // now you can call "saveCallback" with impunity!
Add Comment
Please, Sign In to add comment