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

Function onWatcherCleanup

packages/reactivity/src/watch.ts:103–118  ·  view source on GitHub ↗
(
  cleanupFn: () => void,
  failSilently = false,
  owner: ReactiveEffect | undefined = activeWatcher,
)

Source from the content-addressed store, hash-verified

101 * By default, the current active effect.
102 */
103export function onWatcherCleanup(
104 cleanupFn: () => void,
105 failSilently = false,
106 owner: ReactiveEffect | undefined = activeWatcher,
107): void {
108 if (owner) {
109 let cleanups = cleanupMap.get(owner)
110 if (!cleanups) cleanupMap.set(owner, (cleanups = []))
111 cleanups.push(cleanupFn)
112 } else if (__DEV__ && !failSilently) {
113 warn(
114 `onWatcherCleanup() was called when there was no active watcher` +
115 ` to associate with.`,
116 )
117 }
118}
119
120export function watch(
121 source: WatchSource | WatchSource[] | WatchEffect | object,

Callers 3

watch.spec.tsFile · 0.90
watchFunction · 0.85
apiWatch.spec.tsFile · 0.85

Calls 4

warnFunction · 0.90
pushMethod · 0.65
getMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected