得鹿梦鱼 得鹿梦鱼

订阅者实现

class Watcher{    constructorvm, expOrFn, cb, options, isRenderWatcher{        if this.vm = vm && isRenderWatcher {            vm._watcher = this        }        if options {            this.deep = !!options.deep            this.user = !!options.user            this.lazy = !!options.lazy            this.sync = !!options.sync            this.before = options.before        } else {            this.deep = this.user = this.lazy = this.sync = false        }        this.cb = cb        this.id = ++uid         this.active = true        this.post = false        this.dirty = this.lazy        this.deps = []        this.newDeps = []        this.depIds = new Set        this.newDepIds = new Set        this.expression = __DEV__ ? expOrFn.toString : ''        if isFunctionexpOrFn {            this.getter = expOrFn        } else {            this.getter = parsePathexpOrFn            if !this.getter {                this.getter = noop            }        }        this.value = this.lazy ? undefined : this.get    }}