angular : $eval & $timeout

$digest: function() {
        var watch, value, last,
            watchers,
            length,
            dirty, ttl = TTL,
            next, current, target = this,
            watchLog = [],
            logIdx, logMsg, asyncTask;

        beginPhase(‘$digest‘);
        // Check for changes to browser url that happened in sync before the call to $digest
        $browser.$$checkUrlChange();

        if (this === $rootScope && applyAsyncId !== null) {
          // If this is the root scope, and $applyAsync has scheduled a deferred $apply(), then
          // cancel the scheduled $apply and flush the queue of expressions to be evaluated.
          $browser.defer.cancel(applyAsyncId);
          flushApplyAsync();
        }

        lastDirtyWatch = null;

        do { // "while dirty" loop
          dirty = false;
          current = target;

          while (asyncQueue.length) { //先跑$eval
            try {
              asyncTask = asyncQueue.shift();
              asyncTask.scope.$eval(asyncTask.expression, asyncTask.locals);
            } catch (e) {
              $exceptionHandler(e);
            }
            lastDirtyWatch = null;
          }

          traverseScopesLoop:
          do { // "traverse the scopes" loop
            if ((watchers = current.$$watchers)) {
              // process our watches
              length = watchers.length;
              while (length--) {
                try {
                  watch = watchers[length];
                  // Most common watches are on primitives, in which case we can short
                  // circuit it with === operator, only when === fails do we use .equals
                  if (watch) {
                    if ((value = watch.get(current)) !== (last = watch.last) &&
                        !(watch.eq
                            ? equals(value, last)
                            : (typeof value === ‘number‘ && typeof last === ‘number‘
                               && isNaN(value) && isNaN(last)))) {
                      dirty = true;
                      lastDirtyWatch = watch;
                      watch.last = watch.eq ? copy(value, null) : value;
                      watch.fn(value, ((last === initWatchVal) ? value : last), current);
                      if (ttl < 5) {
                        logIdx = 4 - ttl;
                        if (!watchLog[logIdx]) watchLog[logIdx] = [];
                        watchLog[logIdx].push({
                          msg: isFunction(watch.exp) ? ‘fn: ‘ + (watch.exp.name || watch.exp.toString()) : watch.exp,
                          newVal: value,
                          oldVal: last
                        });
                      }
                    } else if (watch === lastDirtyWatch) {
                      // If the most recently dirty watcher is now clean, short circuit since the remaining watchers
                      // have already been tested.
                      dirty = false;
                      break traverseScopesLoop;
                    }
                  }
                } catch (e) {
                  $exceptionHandler(e);
                }
              }
            }

            // Insanity Warning: scope depth-first traversal
            // yes, this code is a bit crazy, but it works and we have tests to prove it!
            // this piece should be kept in sync with the traversal in $broadcast
            if (!(next = ((current.$$watchersCount && current.$$childHead) ||
                (current !== target && current.$$nextSibling)))) {
              while (current !== target && !(next = current.$$nextSibling)) {
                current = current.$parent;
              }
            }
          } while ((current = next));

          // `break traverseScopesLoop;` takes us to here

          if ((dirty || asyncQueue.length) && !(ttl--)) {
            clearPhase();
            throw $rootScopeMinErr(‘infdig‘,
                ‘{0} $digest() iterations reached. Aborting!\n‘ +
                ‘Watchers fired in the last 5 iterations: {1}‘,
                TTL, watchLog);
          }

        } while (dirty || asyncQueue.length);

        clearPhase();

        while (postDigestQueue.length) {//最后跑$timeout
          try {
            postDigestQueue.shift()();
          } catch (e) {
            $exceptionHandler(e);
          }
        }
      },

angular digest 会先跑 $browser.$$checkUrlChange();, 其他的我带过,接着就是check dirty 和 asyncQueue.length。 最后是check postDigestQuese.length

时间: 2024-10-13 06:52:43

angular : $eval & $timeout的相关文章

.Net Core Web Api实践(四)填坑连接Redis时Timeout performing EVAL

前言:前两篇文章.net core+Redis+IIS+nginx实现Session共享中,介绍了使用Microsoft.Extensions.Caching.Redis实现Session共享的方法,但是高并发时会有连接Redis出现Timeout的问题,这篇文章将介绍该问题的解决方案. 1.环境及工具准备 操作系统:windows10 数据库:Redis 压力测试工具:JMeter(传送门) 2.背景介绍 项目迁移到.net core并上线以后,运行没多久接口就频繁罢工,容器没有挂,redis

Java_Hbase Timeout issue

设置参数hbase.rpc.timeout <property><name>hbase.regionserver.lease.period</name><value>180000</value></property> <property> <name>zookeeper.session.timeout</name> <value>120000</value> </pro

mysql Lock wait timeout exceeded

MySQL 事务没有提交导致 锁等待 Lock wait timeout exceeded java.lang.Exception:### Error updating database.  Cause: java.sql.SQLException: Lock wait timeout exceeded; try restarting transaction### The error may involve defaultParameterMap### The error occurred wh

cisco vpn timeout

Configuration > Remote Access VPN > Network (Client) Access > Advanced > Endpoint Security > Global NAC Parameters cisco vpn timeout,布布扣,bubuko.com

AngularJS中$timeout和$interval的用法详解

1. 先将$interval,$timeout,作为参数注入到controller中,例如rds.controller('controllerCtrl', ['app', '$scope','$http','$routeParams','$filter','$location','$interval','$timeout', function (app, $scope,$http,$routeParams,$filter,$location,$interval,$timeout) {2.在需要用

使用puTTY或Xshell连接阿里云TimeOut超时

根据网上很多主流的说法,我依次检查了 ssh: service sshd status 防火墙:service iptables stop (CentOS 7好像已经没有这个iptable了) 都没有什么问题,最后我在Windows端 Telnet了以下服务器,还是TimeOut. 这个时候我注意到了阿里云有一个自带的安全组,设置了一下就可以了. 具体如下: 当然阿里云本身在这方面有很健全的文档,更多的需求可以查看下面的链接: 安全组应用案例

go get timeout解决Ubuntu16.04VPN配置

博主在使用Micro开源框架里的例子时go get github.com/micro/examples/service,service这个例子依赖的golang.org/x/net目录库全被墙了报一堆timeout.所以写一篇Ubuntu16.04下VPN配置的步骤: 申请一个VPN账号 以这个网站:http://www.samiman.com/index.html为例子. 先购买一个最便宜的包月账号:TerryTong914,密码:XXX,再http://www.samiman.com/xia

解决 Docker pull 出现的net/http: TLS handshake timeout 的一个办法

docker pull 时发生以下错误: 原因:不可描述(政府屏蔽了?) 解决思路:百度搜了下net/http: TLS handshake timeout 出现一个这个结果比较满意 http://dockone.io/article/876?utm_source=tuicool&utm_medium=referral 我不用官方的dockhub了,转而使用国内的仓库daocloud $ echo "DOCKER_OPTS=\"\$DOCKER_OPTS --registry-

Batch containing 1 record(s) expired due to timeout while requesting metadata from brokers

一.异常信息如下: java.util.concurrent.ExecutionException: org.apache.kafka.common.errors.TimeoutException: Batch containing 1 record(s) expired due to timeout while requesting metadata from brokers for user-video-0 at org.apache.kafka.clients.producer.inter

更改pip安装源的镜像解决安装总是timeout的情况

由于国外的pip源总是由于各种原因不能被访问或者网速过慢,而造成的timeout错误 解决方法是修改pip的配置文件(如果没有配置文件在相应的地方新建,配置文件的路径和名字参考这里),设置安装包时候访问的镜像,将其改为国内的镜像 然后设置timeout的时间长一些 例如配置文件设置如下: [global]timeout = 60index-url = http://pypi.douban.com/simple [install]use-mirrors = truemirrors = http:/