diff options
| author | Misko Hevery | 2010-12-10 13:55:18 -0800 | 
|---|---|---|
| committer | Igor Minar | 2011-01-07 14:39:46 -0800 | 
| commit | 47c454a315b6c0260c8f65e70ae9b30f924650df (patch) | |
| tree | 3392daf6242d540a6f3d7bb08ef4914aa46c667e /src/Browser.js | |
| parent | 16086aa37c5c0c98f5c4a42d2a15136bb6d18605 (diff) | |
| download | angular.js-47c454a315b6c0260c8f65e70ae9b30f924650df.tar.bz2 | |
change to keydown from keyup; add delayed $updateView
 - There was a perceived lag when typing do to the fact that we were
   listening on the keyup event instead of keydown. The issue with
   keydown is that we can not read the value of the input field. To
   solve this we schedule a defer call and perform the model update
   then.
 - To prevent calling $eval on root scope too many times as well as to
   prevent drowning the browser with too many updates we now call the
   $eval only after 25ms and any additional requests get ignored. The
   new update service is called $updateView
Diffstat (limited to 'src/Browser.js')
| -rw-r--r-- | src/Browser.js | 15 | 
1 files changed, 7 insertions, 8 deletions
| diff --git a/src/Browser.js b/src/Browser.js index c93f115c..377c740c 100644 --- a/src/Browser.js +++ b/src/Browser.js @@ -136,9 +136,7 @@ function Browser(window, document, body, XHR, $log) {     * @methodOf angular.service.$browser     */    self.poll = function() { -    foreach(pollFns, function(pollFn){  -      pollFn(); -    }); +    foreach(pollFns, function(pollFn){ pollFn(); });    };    /** @@ -319,22 +317,23 @@ function Browser(window, document, body, XHR, $log) {    /**     * @workInProgress -   * @ngdoc +   * @ngdoc method     * @name angular.service.$browser#defer     * @methodOf angular.service.$browser +   * @param {function()} fn A function, who's execution should be defered. +   * @param {int=} [delay=0] of milliseconds to defer the function execution.     *     * @description -   * Executes a fn asynchroniously via `setTimeout(fn, 0)`. +   * Executes a fn asynchroniously via `setTimeout(fn, delay)`.     *     * Unlike when calling `setTimeout` directly, in test this function is mocked and instead of using     * `setTimeout` in tests, the fns are queued in an array, which can be programaticaly flushed via     * `$browser.defer.flush()`.     * -   * @param {function()} fn A function, who's execution should be defered.     */ -  self.defer = function(fn) { +  self.defer = function(fn, delay) {      outstandingRequestCount++; -    setTimeout(function() { completeOutstandingRequest(fn); }, 0); +    setTimeout(function() { completeOutstandingRequest(fn); }, delay || 0);    };    ////////////////////////////////////////////////////////////// | 
