WATCH_CLEANUP,
}
-type WatchEffect = (onCleanup: OnCleanup) => void
-type WatchSource<T = any> = Ref<T> | ComputedRef<T> | (() => T)
-type WatchCallback<V = any, OV = any> = (
+export type WatchEffect = (onCleanup: OnCleanup) => void
+
+export type WatchSource<T = any> = Ref<T, any> | ComputedRef<T> | (() => T)
+
+export type WatchCallback<V = any, OV = any> = (
value: V,
oldValue: OV,
onCleanup: OnCleanup,
) => any
-type OnCleanup = (cleanupFn: () => void) => void
+
+export type OnCleanup = (cleanupFn: () => void) => void
export interface WatchOptions<Immediate = boolean> extends DebuggerOptions {
immediate?: Immediate
import {
type WatchOptions as BaseWatchOptions,
- type ComputedRef,
type DebuggerOptions,
type ReactiveMarker,
- type Ref,
+ type WatchCallback,
+ type WatchEffect,
type WatchHandle,
+ type WatchSource,
watch as baseWatch,
} from '@vue/reactivity'
import { type SchedulerJob, SchedulerJobFlags, queueJob } from './scheduler'
import type { ObjectWatchOptionItem } from './componentOptions'
import { useSSRContext } from './helpers/useSsrContext'
-export type { WatchHandle, WatchStopHandle } from '@vue/reactivity'
-
-export type WatchEffect = (onCleanup: OnCleanup) => void
-
-export type WatchSource<T = any> = Ref<T, any> | ComputedRef<T> | (() => T)
-
-export type WatchCallback<V = any, OV = any> = (
- value: V,
- oldValue: OV,
- onCleanup: OnCleanup,
-) => any
+export type {
+ WatchHandle,
+ WatchStopHandle,
+ WatchEffect,
+ WatchSource,
+ WatchCallback,
+ OnCleanup,
+} from '@vue/reactivity'
type MaybeUndefined<T, I> = I extends true ? T | undefined : T
: never
}
-export type OnCleanup = (cleanupFn: () => void) => void
-
-export interface WatchOptionsBase extends DebuggerOptions {
+export interface WatchEffectOptions extends DebuggerOptions {
flush?: 'pre' | 'post' | 'sync'
}
-export interface WatchOptions<Immediate = boolean> extends WatchOptionsBase {
+export interface WatchOptions<Immediate = boolean> extends WatchEffectOptions {
immediate?: Immediate
deep?: boolean | number
once?: boolean
// Simple effect.
export function watchEffect(
effect: WatchEffect,
- options?: WatchOptionsBase,
+ options?: WatchEffectOptions,
): WatchHandle {
return doWatch(effect, null, options)
}