} from './errorHandling'
import { onBeforeUnmount } from './apiLifecycle'
import { queuePostRenderEffect } from './createRenderer'
+import { WatchHandler } from './apiOptions'
export interface WatchOptions {
lazy?: boolean
// overload #2: single source + cb
export function watch<T>(
source: WatcherSource<T>,
- cb: (newValue: T, oldValue: T, onCleanup: CleanupRegistrator) => any,
+ cb: WatchHandler<T>,
options?: WatchOptions
): StopHandle
): StopHandle
// implementation
-export function watch(
- effectOrSource:
- | WatcherSource<unknown>
- | WatcherSource<unknown>[]
- | SimpleEffect,
- cbOrOptions?:
- | ((value: any, oldValue: any, onCleanup: CleanupRegistrator) => any)
- | WatchOptions,
+export function watch<T = any>(
+ effectOrSource: WatcherSource<T> | WatcherSource<T>[] | SimpleEffect,
+ cbOrOptions?: WatchHandler<T> | WatchOptions,
options?: WatchOptions
): StopHandle {
if (isFunction(cbOrOptions)) {