|
@@ -27,6 +27,7 @@ export default class Watcher {
|
|
|
deep: boolean;
|
|
deep: boolean;
|
|
|
user: boolean;
|
|
user: boolean;
|
|
|
lazy: boolean;
|
|
lazy: boolean;
|
|
|
|
|
+ sync: boolean;
|
|
|
dirty: boolean;
|
|
dirty: boolean;
|
|
|
active: boolean;
|
|
active: boolean;
|
|
|
deps: Array<Dep>;
|
|
deps: Array<Dep>;
|
|
@@ -48,6 +49,7 @@ export default class Watcher {
|
|
|
this.deep = !!options.deep
|
|
this.deep = !!options.deep
|
|
|
this.user = !!options.user
|
|
this.user = !!options.user
|
|
|
this.lazy = !!options.lazy
|
|
this.lazy = !!options.lazy
|
|
|
|
|
+ this.sync = !!options.sync
|
|
|
this.expression = expOrFn.toString()
|
|
this.expression = expOrFn.toString()
|
|
|
this.cb = cb
|
|
this.cb = cb
|
|
|
this.id = ++uid // uid for batching
|
|
this.id = ++uid // uid for batching
|
|
@@ -167,8 +169,11 @@ export default class Watcher {
|
|
|
* Will be called when a dependency changes.
|
|
* Will be called when a dependency changes.
|
|
|
*/
|
|
*/
|
|
|
update () {
|
|
update () {
|
|
|
|
|
+ /* istanbul ignore else */
|
|
|
if (this.lazy) {
|
|
if (this.lazy) {
|
|
|
this.dirty = true
|
|
this.dirty = true
|
|
|
|
|
+ } else if (this.sync) {
|
|
|
|
|
+ this.run()
|
|
|
} else {
|
|
} else {
|
|
|
queueWatcher(this)
|
|
queueWatcher(this)
|
|
|
}
|
|
}
|