Browse Source

sync watcher

Evan You 11 years ago
parent
commit
ae2432e25b
1 changed files with 3 additions and 1 deletions
  1. 3 1
      src/watcher.js

+ 3 - 1
src/watcher.js

@@ -18,6 +18,7 @@ var uid = 0
  *                 - {Boolean} twoWay
  *                 - {Boolean} twoWay
  *                 - {Boolean} deep
  *                 - {Boolean} deep
  *                 - {Boolean} user
  *                 - {Boolean} user
+ *                 - {Boolean} sync
  *                 - {Function} [preProcess]
  *                 - {Function} [preProcess]
  * @constructor
  * @constructor
  */
  */
@@ -34,6 +35,7 @@ function Watcher (vm, expOrFn, cb, options) {
   this.deep = !!options.deep
   this.deep = !!options.deep
   this.user = !!options.user
   this.user = !!options.user
   this.twoWay = !!options.twoWay
   this.twoWay = !!options.twoWay
+  this.sync = !!options.sync
   this.filters = options.filters
   this.filters = options.filters
   this.preProcess = options.preProcess
   this.preProcess = options.preProcess
   this.deps = []
   this.deps = []
@@ -160,7 +162,7 @@ p.afterGet = function () {
  */
  */
 
 
 p.update = function () {
 p.update = function () {
-  if (!config.async) {
+  if (this.sync || !config.async) {
     this.run()
     this.run()
   } else {
   } else {
     batcher.push(this)
     batcher.push(this)