mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-26 11:10:25 +00:00
we now have two types of namespaces: - true namespace: angular.* - used for all global apis - virtual namespace: ng.*, ngMock.*, ... - used for all DI modules the virual namespaces have services under the second namespace level (e.g. ng.) and filters and directives prefixed with filter: and directive: respectively (e.g. ng.filter:orderBy, ng.directive:ngRepeat) this simplifies urls and makes them a lot shorter while still avoiding name collisions
49 lines
1.5 KiB
JavaScript
49 lines
1.5 KiB
JavaScript
'use strict';
|
|
|
|
/**
|
|
* @ngdoc function
|
|
* @name ng.$defer
|
|
* @deprecated Made obsolete by $timeout service. Please migrate your code. This service will be
|
|
* removed with 1.0 final.
|
|
* @requires $browser
|
|
*
|
|
* @description
|
|
* Delegates to {@link ng.$browser#defer $browser.defer}, but wraps the `fn` function
|
|
* into a try/catch block and delegates any exceptions to
|
|
* {@link ng.$exceptionHandler $exceptionHandler} service.
|
|
*
|
|
* In tests you can use `$browser.defer.flush()` to flush the queue of deferred functions.
|
|
*
|
|
* @param {function()} fn A function, who's execution should be deferred.
|
|
* @param {number=} [delay=0] of milliseconds to defer the function execution.
|
|
* @returns {*} DeferId that can be used to cancel the task via `$defer.cancel()`.
|
|
*/
|
|
|
|
/**
|
|
* @ngdoc function
|
|
* @name ng.$defer#cancel
|
|
* @methodOf ng.$defer
|
|
*
|
|
* @description
|
|
* Cancels a defered task identified with `deferId`.
|
|
*
|
|
* @param {*} deferId Token returned by the `$defer` function.
|
|
* @returns {boolean} Returns `true` if the task hasn't executed yet and was successfuly canceled.
|
|
*/
|
|
function $DeferProvider(){
|
|
this.$get = ['$rootScope', '$browser', '$log', function($rootScope, $browser, $log) {
|
|
$log.warn('$defer service has been deprecated, migrate to $timeout');
|
|
|
|
function defer(fn, delay) {
|
|
return $browser.defer(function() {
|
|
$rootScope.$apply(fn);
|
|
}, delay);
|
|
}
|
|
|
|
defer.cancel = function(deferId) {
|
|
return $browser.defer.cancel(deferId);
|
|
};
|
|
|
|
return defer;
|
|
}];
|
|
}
|