From 9af7a9198e2d30608ea6c40eedde03e44a6ef569 Mon Sep 17 00:00:00 2001 From: Igor Minar Date: Tue, 12 Jun 2012 00:35:28 -0700 Subject: fix($defer): remove deprecated $defer service --- src/AngularPublic.js | 1 - src/bootstrap/bootstrap-prettify.js | 2 +- src/ng/defer.js | 49 ------------------------------------- src/ngMock/angular-mocks.js | 5 ---- 4 files changed, 1 insertion(+), 56 deletions(-) delete mode 100644 src/ng/defer.js (limited to 'src') diff --git a/src/AngularPublic.js b/src/AngularPublic.js index 54536b43..61c77af3 100644 --- a/src/AngularPublic.js +++ b/src/AngularPublic.js @@ -109,7 +109,6 @@ function publishExternalAPI(angular){ $browser: $BrowserProvider, $cacheFactory: $CacheFactoryProvider, $controller: $ControllerProvider, - $defer: $DeferProvider, $document: $DocumentProvider, $exceptionHandler: $ExceptionHandlerProvider, $filter: $FilterProvider, diff --git a/src/bootstrap/bootstrap-prettify.js b/src/bootstrap/bootstrap-prettify.js index a4eb52f2..b458c832 100644 --- a/src/bootstrap/bootstrap-prettify.js +++ b/src/bootstrap/bootstrap-prettify.js @@ -198,7 +198,7 @@ directive.ngEmbedApp = ['$templateCache', '$browser', '$rootScope', '$location', }]; this.html5Mode = angular.noop; }); - $provide.decorator('$defer', ['$rootScope', '$delegate', function($rootScope, $delegate) { + $provide.decorator('$timeout', ['$rootScope', '$delegate', function($rootScope, $delegate) { return angular.extend(function(fn, delay) { if (delay && delay > 50) { return setTimeout(function() { diff --git a/src/ng/defer.js b/src/ng/defer.js deleted file mode 100644 index 850d9cf5..00000000 --- a/src/ng/defer.js +++ /dev/null @@ -1,49 +0,0 @@ -'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; - }]; -} diff --git a/src/ngMock/angular-mocks.js b/src/ngMock/angular-mocks.js index 7d11a99d..f1b2223b 100644 --- a/src/ngMock/angular-mocks.js +++ b/src/ngMock/angular-mocks.js @@ -27,11 +27,6 @@ angular.mock = {}; * * The api of this service is the same as that of the real {@link ng.$browser $browser}, except * that there are several helper methods available which can be used in tests. - * - * The following apis can be used in tests: - * - * - $browser.defer — enables testing of code that uses - * {@link ng.$defer $defer} for executing functions via the `setTimeout` api. */ angular.mock.$BrowserProvider = function() { this.$get = function(){ -- cgit v1.2.3