]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
refactor: use consistent name for watch invalidation register function
authorEvan You <yyx990803@gmail.com>
Wed, 26 Feb 2020 15:12:32 +0000 (10:12 -0500)
committerEvan You <yyx990803@gmail.com>
Wed, 26 Feb 2020 15:20:30 +0000 (10:20 -0500)
packages/runtime-core/src/apiWatch.ts
packages/runtime-core/src/index.ts

index eb322bd2f5b1acbe2f5d3aceaa792998a05dd58d..889821a72a2bb85ec91e80ce10cb072e3b30ca06 100644 (file)
@@ -34,14 +34,14 @@ import { onBeforeUnmount } from './apiLifecycle'
 import { queuePostRenderEffect } from './renderer'
 import { warn } from './warning'
 
-export type WatchEffect = (onCleanup: CleanupRegistrator) => void
+export type WatchEffect = (onInvalidate: InvalidateCbRegistrator) => void
 
 export type WatchSource<T = any> = Ref<T> | ComputedRef<T> | (() => T)
 
 export type WatchCallback<V = any, OV = any> = (
   value: V,
   oldValue: OV,
-  onCleanup: CleanupRegistrator
+  onInvalidate: InvalidateCbRegistrator
 ) => any
 
 type MapSources<T> = {
@@ -54,7 +54,7 @@ type MapOldSources<T, Immediate> = {
     : never
 }
 
-export type CleanupRegistrator = (invalidate: () => void) => void
+type InvalidateCbRegistrator = (cb: () => void) => void
 
 export interface BaseWatchOptions {
   flush?: 'pre' | 'post' | 'sync'
@@ -169,7 +169,7 @@ function doWatch(
         source,
         instance,
         ErrorCodes.WATCH_CALLBACK,
-        [registerCleanup]
+        [onInvalidate]
       )
     }
   }
@@ -180,7 +180,7 @@ function doWatch(
   }
 
   let cleanup: Function
-  const registerCleanup: CleanupRegistrator = (fn: () => void) => {
+  const onInvalidate: InvalidateCbRegistrator = (fn: () => void) => {
     cleanup = runner.options.onStop = () => {
       callWithErrorHandling(fn, instance, ErrorCodes.WATCH_CLEANUP)
     }
@@ -195,7 +195,7 @@ function doWatch(
       callWithAsyncErrorHandling(cb, instance, ErrorCodes.WATCH_CALLBACK, [
         getter(),
         undefined,
-        registerCleanup
+        onInvalidate
       ])
     }
     return NOOP
@@ -217,7 +217,7 @@ function doWatch(
             newValue,
             // pass undefined as the old value when it's changed for the first time
             oldValue === INITIAL_WATCHER_VALUE ? undefined : oldValue,
-            registerCleanup
+            onInvalidate
           ])
           oldValue = newValue
         }
index 634d53b424b89ca5cf25389cfb6f11e2266b966d..4e9459d4afa0ca7d1e5bd3b75a0c51e7452cf6bc 100644 (file)
@@ -152,7 +152,6 @@ export {
   // types
   WatchOptions,
   WatchCallback,
-  CleanupRegistrator,
   WatchSource,
   StopHandle
 } from './apiWatch'