Просмотр исходного кода

increase batcher max update count and allow it to be configured (close #950)

Evan You 11 лет назад
Родитель
Сommit
e81bd43c28
2 измененных файлов с 10 добавлено и 4 удалено
  1. 3 3
      src/batcher.js
  2. 7 1
      src/config.js

+ 3 - 3
src/batcher.js

@@ -1,5 +1,5 @@
 var _ = require('./util')
 var _ = require('./util')
-var MAX_UPDATE_COUNT = 10
+var config = require('./config')
 
 
 // we have two separate queues: one for directive updates
 // we have two separate queues: one for directive updates
 // and one for user watcher registered via $watch().
 // and one for user watcher registered via $watch().
@@ -70,7 +70,7 @@ exports.push = function (job) {
     } else {
     } else {
       has[id]++
       has[id]++
       // detect possible infinite update loops
       // detect possible infinite update loops
-      if (has[id] > MAX_UPDATE_COUNT) {
+      if (has[id] > config._maxUpdateCount) {
         _.warn(
         _.warn(
           'You may have an infinite update loop for the ' +
           'You may have an infinite update loop for the ' +
           'watcher with expression: "' + job.expression + '".'
           'watcher with expression: "' + job.expression + '".'
@@ -92,4 +92,4 @@ exports.push = function (job) {
       _.nextTick(flush)
       _.nextTick(flush)
     }
     }
   }
   }
-}
+}

+ 7 - 1
src/config.js

@@ -85,7 +85,13 @@ module.exports = {
     ONE_WAY: 0,
     ONE_WAY: 0,
     TWO_WAY: 1,
     TWO_WAY: 1,
     ONE_TIME: 2
     ONE_TIME: 2
-  }
+  },
+
+  /**
+   * Max circular updates allowed in a batcher flush cycle.
+   */
+
+  _maxUpdateCount: 100
 
 
 }
 }