Skip to content

Commit e42d6b0

Browse files
committed
refactor: use consistent name for watch invalidation register function
1 parent 04f83fa commit e42d6b0

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

packages/runtime-core/src/apiWatch.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,14 @@ import { onBeforeUnmount } from './apiLifecycle'
3434
import { queuePostRenderEffect } from './renderer'
3535
import { warn } from './warning'
3636

37-
export type WatchEffect = (onCleanup: CleanupRegistrator) => void
37+
export type WatchEffect = (onInvalidate: InvalidateCbRegistrator) => void
3838

3939
export type WatchSource<T = any> = Ref<T> | ComputedRef<T> | (() => T)
4040

4141
export type WatchCallback<V = any, OV = any> = (
4242
value: V,
4343
oldValue: OV,
44-
onCleanup: CleanupRegistrator
44+
onInvalidate: InvalidateCbRegistrator
4545
) => any
4646

4747
type 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

5959
export 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
}

packages/runtime-core/src/index.ts

-1
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,6 @@ export {
152152
// types
153153
WatchOptions,
154154
WatchCallback,
155-
CleanupRegistrator,
156155
WatchSource,
157156
StopHandle
158157
} from './apiWatch'

0 commit comments

Comments
 (0)