Created
February 7, 2014 09:49
-
-
Save IlanFrumer/8859868 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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; | |
}; | |
}]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
http://plnkr.co/edit/pnVPzDM7BboMltAkIADx?p=info