( this: ComponentInternalInstance, source: string | Function, value: WatchCallback | ObjectWatchOptionItem, options?: WatchOptions, )
| 243 | |
| 244 | // this.$watch |
| 245 | export function instanceWatch( |
| 246 | this: ComponentInternalInstance, |
| 247 | source: string | Function, |
| 248 | value: WatchCallback | ObjectWatchOptionItem, |
| 249 | options?: WatchOptions, |
| 250 | ): WatchHandle { |
| 251 | const publicThis = this.proxy |
| 252 | const getter = isString(source) |
| 253 | ? source.includes('.') |
| 254 | ? createPathGetter(publicThis!, source) |
| 255 | : () => publicThis![source as keyof typeof publicThis] |
| 256 | : source.bind(publicThis, publicThis) |
| 257 | let cb |
| 258 | if (isFunction(value)) { |
| 259 | cb = value |
| 260 | } else { |
| 261 | cb = value.handler as Function |
| 262 | options = value |
| 263 | } |
| 264 | const reset = setCurrentInstance(this) |
| 265 | const res = doWatch(getter, cb.bind(publicThis), options) |
| 266 | reset() |
| 267 | return res |
| 268 | } |
| 269 | |
| 270 | export function createPathGetter( |
| 271 | ctx: ComponentPublicInstance, |
nothing calls this directly
no test coverage detected