This repository was archived by the owner on Apr 12, 2024. It is now read-only.
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
Provide interface to clear $defer's #469
Closed
Description
It's possible to call window.clearTimeout() with the result of window.setTimeout() , but not so with $defer service.
Please either provide a way to clear $defer's within angular.js or return result of setTimeout, so it can be cleared outside.
self.defer = function(fn, delay) {
outstandingRequestCount++;
// ADDED return:
return setTimeout(function() { completeOutstandingRequest(fn); }, delay || 0);
};
angularServiceInject('$defer', function($browser, $exceptionHandler, $updateView) {
return function(fn, delay) {
// ADDED return:
return $browser.defer(function() {
try {
fn();
} catch(e) {
$exceptionHandler(e);
} finally {
$updateView();
}
}, delay);
};
}, ['$browser', '$exceptionHandler', '$updateView']);