From: Evan You Date: Mon, 27 Apr 2020 17:33:57 +0000 (-0400) Subject: types: use more consistent naming for apiWatch type exports X-Git-Tag: v3.0.0-beta.5~16 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=892fb6d2290516df44241992b62d65f1376f611a;p=thirdparty%2Fvuejs%2Fcore.git types: use more consistent naming for apiWatch type exports BREAKING CHANGE: Some watch API types are renamed. - `BaseWatchOptions` -> `WatchOptionsBase` - `StopHandle` -> `WatchStopHandle` --- diff --git a/packages/runtime-core/src/apiWatch.ts b/packages/runtime-core/src/apiWatch.ts index c1802e4818..13e5ab0277 100644 --- a/packages/runtime-core/src/apiWatch.ts +++ b/packages/runtime-core/src/apiWatch.ts @@ -54,26 +54,26 @@ type MapOldSources = { type InvalidateCbRegistrator = (cb: () => void) => void -export interface BaseWatchOptions { +export interface WatchOptionsBase { flush?: 'pre' | 'post' | 'sync' onTrack?: ReactiveEffectOptions['onTrack'] onTrigger?: ReactiveEffectOptions['onTrigger'] } -export interface WatchOptions extends BaseWatchOptions { +export interface WatchOptions extends WatchOptionsBase { immediate?: Immediate deep?: boolean } -export type StopHandle = () => void +export type WatchStopHandle = () => void const invoke = (fn: Function) => fn() // Simple effect. export function watchEffect( effect: WatchEffect, - options?: BaseWatchOptions -): StopHandle { + options?: WatchOptionsBase +): WatchStopHandle { return doWatch(effect, null, options) } @@ -85,7 +85,7 @@ export function watch = false>( source: WatchSource, cb: WatchCallback, options?: WatchOptions -): StopHandle +): WatchStopHandle // overload #2: array of multiple sources + cb // Readonly constraint helps the callback to correctly infer value types based @@ -98,14 +98,14 @@ export function watch< sources: T, cb: WatchCallback, MapOldSources>, options?: WatchOptions -): StopHandle +): WatchStopHandle // implementation export function watch( source: WatchSource | WatchSource[], cb: WatchCallback, options?: WatchOptions -): StopHandle { +): WatchStopHandle { if (__DEV__ && !isFunction(cb)) { warn( `\`watch(fn, options?)\` signature has been moved to a separate API. ` + @@ -120,7 +120,7 @@ function doWatch( source: WatchSource | WatchSource[] | WatchEffect, cb: WatchCallback | null, { immediate, deep, flush, onTrack, onTrigger }: WatchOptions = EMPTY_OBJ -): StopHandle { +): WatchStopHandle { if (__DEV__ && !cb) { if (immediate !== undefined) { warn( @@ -274,7 +274,7 @@ export function instanceWatch( source: string | Function, cb: Function, options?: WatchOptions -): StopHandle { +): WatchStopHandle { const publicThis = this.proxy as any const getter = isString(source) ? () => publicThis[source] diff --git a/packages/runtime-core/src/index.ts b/packages/runtime-core/src/index.ts index 3c008c86c6..57812f3461 100644 --- a/packages/runtime-core/src/index.ts +++ b/packages/runtime-core/src/index.ts @@ -159,11 +159,11 @@ export { export { // types WatchEffect, - BaseWatchOptions, WatchOptions, + WatchOptionsBase, WatchCallback, WatchSource, - StopHandle + WatchStopHandle } from './apiWatch' export { InjectionKey } from './apiInject' export {