( cleanupFn: () => void, failSilently = false, owner: ReactiveEffect | undefined = activeWatcher, )
| 101 | * By default, the current active effect. |
| 102 | */ |
| 103 | export 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 | |
| 120 | export function watch( |
| 121 | source: WatchSource | WatchSource[] | WatchEffect | object, |
no test coverage detected