diff options
| author | Misko Hevery | 2010-12-08 16:52:08 -0800 |
|---|---|---|
| committer | Igor Minar | 2011-01-04 16:40:40 -0800 |
| commit | d0270d92568e1b7c762b42a0ee0712b65d9acc5c (patch) | |
| tree | 2a0f0680e6f9713c8c7a2c01d50e7a97d8b01d11 /src | |
| parent | 5f080193cbc0d84676cf267adcdc6307fb601610 (diff) | |
| download | angular.js-d0270d92568e1b7c762b42a0ee0712b65d9acc5c.tar.bz2 | |
Remove many eager-publish services, lazy polling
- Browser now starts the poller on first call to addPollFn()
- Many services ($location, $cookies, $router) are no longer eager-publish. The result is that
unless someone needs the $cookies, they will not cause the Browser to start polling for them.
Diffstat (limited to 'src')
| -rw-r--r-- | src/AngularPublic.js | 9 | ||||
| -rw-r--r-- | src/Browser.js | 4 | ||||
| -rw-r--r-- | src/services.js | 6 |
3 files changed, 13 insertions, 6 deletions
diff --git a/src/AngularPublic.js b/src/AngularPublic.js index af572340..38325404 100644 --- a/src/AngularPublic.js +++ b/src/AngularPublic.js @@ -17,11 +17,16 @@ angularService('$browser', function($log){ XHR, $log, window.setTimeout); - browserSingleton.startPoller(50, function(delay, fn){setTimeout(delay,fn);}); + var addPollFn = browserSingleton.addPollFn; + browserSingleton.addPollFn = function(){ + browserSingleton.addPollFn = addPollFn; + browserSingleton.startPoller(100, function(delay, fn){setTimeout(delay,fn);}); + return addPollFn.apply(browserSingleton, arguments); + }; browserSingleton.bind(); } return browserSingleton; -}, {inject:['$log']}); +}, {$inject:['$log']}); extend(angular, { 'element': jqLite, diff --git a/src/Browser.js b/src/Browser.js index 94807a8c..4ab92f10 100644 --- a/src/Browser.js +++ b/src/Browser.js @@ -115,7 +115,9 @@ function Browser(location, document, head, XHR, $log, setTimeout) { * @methodOf angular.service.$browser */ self.poll = function() { - foreach(pollFns, function(pollFn){ pollFn(); }); + foreach(pollFns, function(pollFn){ + pollFn(); + }); }; /** diff --git a/src/services.js b/src/services.js index 36c43564..5356d612 100644 --- a/src/services.js +++ b/src/services.js @@ -295,7 +295,7 @@ angularServiceInject("$location", function(browser) { return h; } -}, ['$browser'], EAGER_PUBLISHED); +}, ['$browser']); /** @@ -678,7 +678,7 @@ angularServiceInject('$route', function(location) { } this.$watch(function(){return dirty + location.hash;}, updateRoute); return $route; -}, ['$location'], EAGER_PUBLISHED); +}, ['$location']); /** * @workInProgress @@ -1124,7 +1124,7 @@ angularServiceInject('$cookies', function($browser) { } } } -}, ['$browser'], EAGER_PUBLISHED); +}, ['$browser']); /** * @workInProgress |
