Appearance
unwatch
javascript
// user watcher 收集 dep 是为了 unwatch
Vue.prototype.$watch = function (
expOrFn: string | (() => any),
cb: any,
options?: Record<string, any>
): Function {
return function unwatchFn() {
watcher.teardown()
}
}
teardown() {
let i = this.deps.length
while (i--) {
this.deps[i].removeSub(this)
}
}