@@ -34,14 +34,14 @@ import { onBeforeUnmount } from './apiLifecycle'
3434import { queuePostRenderEffect } from './renderer'
3535import { warn } from './warning'
3636
37- export type WatchEffect = ( onCleanup : CleanupRegistrator ) => void
37+ export type WatchEffect = ( onInvalidate : InvalidateCbRegistrator ) => void
3838
3939export type WatchSource < T = any > = Ref < T > | ComputedRef < T > | ( ( ) => T )
4040
4141export type WatchCallback < V = any , OV = any > = (
4242 value : V ,
4343 oldValue : OV ,
44- onCleanup : CleanupRegistrator
44+ onInvalidate : InvalidateCbRegistrator
4545) => any
4646
4747type MapSources < T > = {
@@ -54,7 +54,7 @@ type MapOldSources<T, Immediate> = {
5454 : never
5555}
5656
57- export type CleanupRegistrator = ( invalidate : ( ) => void ) => void
57+ type InvalidateCbRegistrator = ( cb : ( ) => void ) => void
5858
5959export interface BaseWatchOptions {
6060 flush ?: 'pre' | 'post' | 'sync'
@@ -169,7 +169,7 @@ function doWatch(
169169 source ,
170170 instance ,
171171 ErrorCodes . WATCH_CALLBACK ,
172- [ registerCleanup ]
172+ [ onInvalidate ]
173173 )
174174 }
175175 }
@@ -180,7 +180,7 @@ function doWatch(
180180 }
181181
182182 let cleanup : Function
183- const registerCleanup : CleanupRegistrator = ( fn : ( ) => void ) => {
183+ const onInvalidate : InvalidateCbRegistrator = ( fn : ( ) => void ) => {
184184 cleanup = runner . options . onStop = ( ) => {
185185 callWithErrorHandling ( fn , instance , ErrorCodes . WATCH_CLEANUP )
186186 }
@@ -195,7 +195,7 @@ function doWatch(
195195 callWithAsyncErrorHandling ( cb , instance , ErrorCodes . WATCH_CALLBACK , [
196196 getter ( ) ,
197197 undefined ,
198- registerCleanup
198+ onInvalidate
199199 ] )
200200 }
201201 return NOOP
@@ -217,7 +217,7 @@ function doWatch(
217217 newValue ,
218218 // pass undefined as the old value when it's changed for the first time
219219 oldValue === INITIAL_WATCHER_VALUE ? undefined : oldValue ,
220- registerCleanup
220+ onInvalidate
221221 ] )
222222 oldValue = newValue
223223 }
0 commit comments