MCPcopy
hub / github.com/vuejs/core / watch

Function watch

packages/runtime-core/src/apiWatch.ts:131–144  ·  view source on GitHub ↗
(
  source: T | WatchSource<T>,
  cb: any,
  options?: WatchOptions<Immediate>,
)

Source from the content-addressed store, hash-verified

129
130// implementation
131export function watch<T = any, Immediate extends Readonly<boolean> = false>(
132 source: T | WatchSource<T>,
133 cb: any,
134 options?: WatchOptions<Immediate>,
135): WatchHandle {
136 if (__DEV__ && !isFunction(cb)) {
137 warn(
138 `\`watch(fn, options?)\` signature has been moved to a separate API. ` +
139 `Use \`watchEffect(fn, options?)\` instead. \`watch\` now only ` +
140 `supports \`watch(source, cb, options?) signature.`,
141 )
142 }
143 return doWatch(source as any, cb, options)
144}
145
146function doWatch(
147 source: WatchSource | WatchSource[] | WatchEffect | object,

Callers 15

handleBeginFunction · 0.90
useCssVarsFunction · 0.90
setupFunction · 0.90
createWatcherFunction · 0.90
setupFunction · 0.90
apiWatch.bench.tsFile · 0.90
setupFunction · 0.50
setupFunction · 0.50
setupFunction · 0.50
setupFunction · 0.50
apiWatch.spec.tsFile · 0.50

Calls 3

isFunctionFunction · 0.90
warnFunction · 0.90
doWatchFunction · 0.85

Tested by 10

handleBeginFunction · 0.72
setupFunction · 0.72
setupFunction · 0.40
setupFunction · 0.40
setupFunction · 0.40
setupFunction · 0.40
setupFunction · 0.40
setupFunction · 0.40
setupFunction · 0.40
setupFunction · 0.40