@@ -34,14 +34,14 @@ import { onBeforeUnmount } from './apiLifecycle'
34
34
import { queuePostRenderEffect } from './renderer'
35
35
import { warn } from './warning'
36
36
37
- export type WatchEffect = ( onCleanup : CleanupRegistrator ) => void
37
+ export type WatchEffect = ( onInvalidate : InvalidateCbRegistrator ) => void
38
38
39
39
export type WatchSource < T = any > = Ref < T > | ComputedRef < T > | ( ( ) => T )
40
40
41
41
export type WatchCallback < V = any , OV = any > = (
42
42
value : V ,
43
43
oldValue : OV ,
44
- onCleanup : CleanupRegistrator
44
+ onInvalidate : InvalidateCbRegistrator
45
45
) => any
46
46
47
47
type MapSources < T > = {
@@ -54,7 +54,7 @@ type MapOldSources<T, Immediate> = {
54
54
: never
55
55
}
56
56
57
- export type CleanupRegistrator = ( invalidate : ( ) => void ) => void
57
+ type InvalidateCbRegistrator = ( cb : ( ) => void ) => void
58
58
59
59
export interface BaseWatchOptions {
60
60
flush ?: 'pre' | 'post' | 'sync'
@@ -169,7 +169,7 @@ function doWatch(
169
169
source ,
170
170
instance ,
171
171
ErrorCodes . WATCH_CALLBACK ,
172
- [ registerCleanup ]
172
+ [ onInvalidate ]
173
173
)
174
174
}
175
175
}
@@ -180,7 +180,7 @@ function doWatch(
180
180
}
181
181
182
182
let cleanup : Function
183
- const registerCleanup : CleanupRegistrator = ( fn : ( ) => void ) => {
183
+ const onInvalidate : InvalidateCbRegistrator = ( fn : ( ) => void ) => {
184
184
cleanup = runner . options . onStop = ( ) => {
185
185
callWithErrorHandling ( fn , instance , ErrorCodes . WATCH_CLEANUP )
186
186
}
@@ -195,7 +195,7 @@ function doWatch(
195
195
callWithAsyncErrorHandling ( cb , instance , ErrorCodes . WATCH_CALLBACK , [
196
196
getter ( ) ,
197
197
undefined ,
198
- registerCleanup
198
+ onInvalidate
199
199
] )
200
200
}
201
201
return NOOP
@@ -217,7 +217,7 @@ function doWatch(
217
217
newValue ,
218
218
// pass undefined as the old value when it's changed for the first time
219
219
oldValue === INITIAL_WATCHER_VALUE ? undefined : oldValue ,
220
- registerCleanup
220
+ onInvalidate
221
221
] )
222
222
oldValue = newValue
223
223
}
0 commit comments