MCPcopy Create free account
hub / github.com/binux/qiandao / timeout

Function timeout

web/static/components/angularjs/angular.js:14227–14251  ·  view source on GitHub ↗

* @ngdoc service * @name $timeout * * @description * Angular's wrapper for `window.setTimeout`. The `fn` function is wrapped into a try/catch * block and delegates any exceptions to * ng.$exceptionHandler $exceptionHandler service. * * The retu

(fn, delay, invokeApply)

Source from the content-addressed store, hash-verified

14225 *
14226 */
14227 function timeout(fn, delay, invokeApply) {
14228 var deferred = $q.defer(),
14229 promise = deferred.promise,
14230 skipApply = (isDefined(invokeApply) && !invokeApply),
14231 timeoutId;
14232
14233 timeoutId = $browser.defer(function() {
14234 try {
14235 deferred.resolve(fn());
14236 } catch(e) {
14237 deferred.reject(e);
14238 $exceptionHandler(e);
14239 }
14240 finally {
14241 delete deferreds[promise.$$timeoutId];
14242 }
14243
14244 if (!skipApply) $rootScope.$apply();
14245 }, delay);
14246
14247 promise.$$timeoutId = timeoutId;
14248 deferreds[timeoutId] = deferred;
14249
14250 return promise;
14251 }
14252
14253
14254 /**

Callers

nothing calls this directly

Calls 1

isDefinedFunction · 0.85

Tested by

no test coverage detected