Skip to content

Instantly share code, notes, and snippets.

@mouseroot
Last active August 29, 2015 14:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mouseroot/ca6ded302b7a337b1cb9 to your computer and use it in GitHub Desktop.
Save mouseroot/ca6ded302b7a337b1cb9 to your computer and use it in GitHub Desktop.
Delay.js - Simple wrapper around setTimout to cleanup the handle refs
(function() {
var Delay;
Delay = function(callback, time, args) {
var _timer;
_timer = setTimeout(function() {
if (!args) {
callback();
} else {
callback(args);
}
clearTimeout(_timer);
}, time);
};
}).call(this);
Delay = (callback, time, args) ->
_timer = setTimeout () ->
if !args
callback()
else
callback args
clearTimeout _timer
return
, time
return
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment