aboutsummaryrefslogtreecommitdiffstats
path: root/src/service
diff options
context:
space:
mode:
Diffstat (limited to 'src/service')
-rw-r--r--src/service/cookies.js2
-rw-r--r--src/service/defer.js4
-rw-r--r--src/service/location.js2
-rw-r--r--src/service/route.js6
-rw-r--r--src/service/updateView.js61
-rw-r--r--src/service/xhr.bulk.js2
-rw-r--r--src/service/xhr.js30
7 files changed, 21 insertions, 86 deletions
diff --git a/src/service/cookies.js b/src/service/cookies.js
index 74e63679..220a6ed5 100644
--- a/src/service/cookies.js
+++ b/src/service/cookies.js
@@ -37,7 +37,7 @@ angularServiceInject('$cookies', function($browser) {
//at the end of each eval, push cookies
//TODO: this should happen before the "delayed" watches fire, because if some cookies are not
// strings or browser refuses to store some cookies, we update the model in the push fn.
- this.$observe(push);
+ this.$watch(push);
return cookies;
diff --git a/src/service/defer.js b/src/service/defer.js
index 0a69912c..1ea4bf0c 100644
--- a/src/service/defer.js
+++ b/src/service/defer.js
@@ -5,8 +5,6 @@
* @ngdoc service
* @name angular.service.$defer
* @requires $browser
- * @requires $exceptionHandler
- * @requires $updateView
*
* @description
* Delegates to {@link angular.service.$browser $browser.defer}, but wraps the `fn` function
@@ -25,4 +23,4 @@ angularServiceInject('$defer', function($browser) {
scope.$apply(fn);
}, delay);
};
-}, ['$browser', '$exceptionHandler', '$updateView']);
+}, ['$browser']);
diff --git a/src/service/location.js b/src/service/location.js
index 23531140..6e646b8b 100644
--- a/src/service/location.js
+++ b/src/service/location.js
@@ -91,7 +91,7 @@ angularServiceInject("$location", function($browser) {
* @description
* Updates the location object.
* Does not immediately update the browser
- * Browser is updated at the end of $flush()
+ * Browser is updated at the end of $digest()
*
* Does not immediately update the browser. Instead the browser is updated at the end of $eval()
* cycle.
diff --git a/src/service/route.js b/src/service/route.js
index e1d0e7be..9b4db0dd 100644
--- a/src/service/route.js
+++ b/src/service/route.js
@@ -62,7 +62,7 @@
</doc:scenario>
</doc:example>
*/
-angularServiceInject('$route', function($location, $updateView) {
+angularServiceInject('$route', function($location) {
var routes = {},
onChange = [],
matcher = switchRouteMatcher,
@@ -267,7 +267,7 @@ angularServiceInject('$route', function($location, $updateView) {
}
- this.$watch(function(){return dirty + $location.hash;}, updateRoute)();
+ this.$watch(function(){return dirty + $location.hash;}, updateRoute);
return $route;
-}, ['$location', '$updateView']);
+}, ['$location']);
diff --git a/src/service/updateView.js b/src/service/updateView.js
deleted file mode 100644
index b51e719b..00000000
--- a/src/service/updateView.js
+++ /dev/null
@@ -1,61 +0,0 @@
-'use strict';
-
-/**
- * @workInProgress
- * @ngdoc service
- * @name angular.service.$updateView
- * @requires $browser
- *
- * @description
- * Calling `$updateView` enqueues the eventual update of the view. (Update the DOM to reflect the
- * model). The update is eventual, since there are often multiple updates to the model which may
- * be deferred. The default update delayed is 25 ms. This means that the view lags the model by
- * that time. (25ms is small enough that it is perceived as instantaneous by the user). The delay
- * can be adjusted by setting the delay property of the service.
- *
- * <pre>angular.service('$updateView').delay = 10</pre>
- *
- * The delay is there so that multiple updates to the model which occur sufficiently close
- * together can be merged into a single update.
- *
- * You don't usually call '$updateView' directly since angular does it for you in most cases,
- * but there are some cases when you need to call it.
- *
- * - `$updateView()` called automatically by angular:
- * - Your Application Controllers: Your controller code is called by angular and hence
- * angular is aware that you may have changed the model.
- * - Your Services: Your service is usually called by your controller code, hence same rules
- * apply.
- * - May need to call `$updateView()` manually:
- * - Widgets / Directives: If you listen to any DOM events or events on any third party
- * libraries, then angular is not aware that you may have changed state state of the
- * model, and hence you need to call '$updateView()' manually.
- * - 'setTimeout'/'XHR': If you call 'setTimeout' (instead of {@link angular.service.$defer})
- * or 'XHR' (instead of {@link angular.service.$xhr}) then you may be changing the model
- * without angular knowledge and you may need to call '$updateView()' directly.
- *
- * Note: if you wish to update the view immediately (without delay), you can do so by calling
- * {@link angular.scope.$apply} at any time from your code:
- * <pre>scope.$apply()</pre>
- *
- * In unit-test mode the update is instantaneous and synchronous to simplify writing tests.
- *
- */
-
-function serviceUpdateViewFactory($browser){
- var rootScope = this;
- var scheduled;
- function update(){
- scheduled = false;
- rootScope.$flush();
- }
- return $browser.isMock ? update : function(){
- if (!scheduled) {
- scheduled = true;
- $browser.defer(update, serviceUpdateViewFactory.delay);
- }
- };
-}
-serviceUpdateViewFactory.delay = 25;
-
-angularServiceInject('$updateView', serviceUpdateViewFactory, ['$browser']);
diff --git a/src/service/xhr.bulk.js b/src/service/xhr.bulk.js
index 816336f8..15bf0c83 100644
--- a/src/service/xhr.bulk.js
+++ b/src/service/xhr.bulk.js
@@ -82,6 +82,6 @@ angularServiceInject('$xhr.bulk', function($xhr, $error, $log){
}
});
};
- this.$observe(bulkXHR.flush);
+ this.$watch(bulkXHR.flush);
return bulkXHR;
}, ['$xhr', '$xhr.error', '$log']);
diff --git a/src/service/xhr.js b/src/service/xhr.js
index 224bc57a..bf882684 100644
--- a/src/service/xhr.js
+++ b/src/service/xhr.js
@@ -10,8 +10,6 @@
* in your tests
* @requires $xhr.error $xhr delegates all non `2xx` response code to this service.
* @requires $log $xhr delegates all exceptions to `$log.error()`.
- * @requires $updateView After a server response the view needs to be updated for data-binding to
- * take effect.
*
* @description
* Generates an XHR request. The $xhr service delegates all requests to
@@ -173,8 +171,8 @@
</doc:scenario>
</doc:example>
*/
-angularServiceInject('$xhr', function($browser, $error, $log, $updateView){
-
+angularServiceInject('$xhr', function($browser, $error, $log){
+ var rootScope = this;
var xhrHeaderDefaults = {
common: {
"Accept": "application/json, text/plain, */*",
@@ -206,19 +204,19 @@ angularServiceInject('$xhr', function($browser, $error, $log, $updateView){
response = fromJson(response, true);
}
}
- if (200 <= code && code < 300) {
- success(code, response);
- } else if (isFunction(error)) {
- error(code, response);
- } else {
- $error(
- {method: method, url: url, data: post, success: success},
- {status: code, body: response});
- }
+ rootScope.$apply(function(){
+ if (200 <= code && code < 300) {
+ success(code, response);
+ } else if (isFunction(error)) {
+ error(code, response);
+ } else {
+ $error(
+ {method: method, url: url, data: post, success: success},
+ {status: code, body: response});
+ }
+ });
} catch (e) {
$log.error(e);
- } finally {
- $updateView();
}
}, extend({'X-XSRF-TOKEN': $browser.cookies()['XSRF-TOKEN']},
xhrHeaderDefaults.common,
@@ -228,4 +226,4 @@ angularServiceInject('$xhr', function($browser, $error, $log, $updateView){
xhr.defaults = {headers: xhrHeaderDefaults};
return xhr;
-}, ['$browser', '$xhr.error', '$log', '$updateView']);
+}, ['$browser', '$xhr.error', '$log']);