Skip to content

Instantly share code, notes, and snippets.

@IlanFrumer
Created February 7, 2014 09:49
Show Gist options
  • Save IlanFrumer/8859868 to your computer and use it in GitHub Desktop.
Save IlanFrumer/8859868 to your computer and use it in GitHub Desktop.
app.factory('timeout', ['$timeout',
function($timeout){
return function $timeoutFactory(){
var promise = null;
function timeout (fn, delay, invokeApply){
$timeout.cancel(promise);
promise = $timeout(function(){
fn();
promise= null;
}, delay, invokeApply);
}
timeout.cancel = function(){
$timeout.cancel(promise);
promise = null;
};
return timeout;
};
}]);
@IlanFrumer
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment