diff --git a/packages/guidelines.md b/packages/guidelines.md index f50089f873b..9d3af9565ac 100644 --- a/packages/guidelines.md +++ b/packages/guidelines.md @@ -97,7 +97,7 @@ export function watchDebounced( source: any, cb: any, options: WatchDebouncedOptions = {}, -): WatchStopHandle { +): WatchHandle { return watch( source, () => { /* ... */ }, diff --git a/packages/rxjs/watchExtractedObservable/index.ts b/packages/rxjs/watchExtractedObservable/index.ts index d6d3823e058..78dd8efc24b 100644 --- a/packages/rxjs/watchExtractedObservable/index.ts +++ b/packages/rxjs/watchExtractedObservable/index.ts @@ -1,6 +1,6 @@ import type { MapOldSources, MapSources, MultiWatchSources } from '@vueuse/shared' import type { Observable, Subscription } from 'rxjs' -import type { WatchOptions, WatchSource, WatchStopHandle } from 'vue' +import type { WatchHandle, WatchOptions, WatchSource } from 'vue' import { tryOnScopeDispose } from '@vueuse/shared' import { watch } from 'vue' @@ -27,7 +27,7 @@ export function watchExtractedObservable< callback: (snapshot: E) => void, subscriptionOptions?: WatchExtractedObservableOptions, watchOptions?: WatchOptions -): WatchStopHandle +): WatchHandle // overload: multiple sources w/ `as const` // watch([foo, bar] as const, () => {}) @@ -46,7 +46,7 @@ export function watchExtractedObservable< callback: (snapshot: E) => void, subscriptionOptions?: WatchExtractedObservableOptions, watchOptions?: WatchOptions -): WatchStopHandle +): WatchHandle // overload: single source + cb export function watchExtractedObservable< @@ -63,7 +63,7 @@ export function watchExtractedObservable< callback: (snapshot: E) => void, subscriptionOptions?: WatchExtractedObservableOptions, watchOptions?: WatchOptions -): WatchStopHandle +): WatchHandle // overload: watching reactive object w/ cb export function watchExtractedObservable< @@ -80,7 +80,7 @@ export function watchExtractedObservable< callback: (snapshot: E) => void, subscriptionOptions?: WatchExtractedObservableOptions, watchOptions?: WatchOptions -): WatchStopHandle +): WatchHandle // implementation export function watchExtractedObservable = false>( @@ -89,7 +89,7 @@ export function watchExtractedObservable void, subscriptionOptions?: WatchExtractedObservableOptions, watchOptions?: WatchOptions, -): WatchStopHandle { +): WatchHandle { let subscription: Subscription | undefined tryOnScopeDispose(() => { diff --git a/packages/shared/watchDebounced/index.ts b/packages/shared/watchDebounced/index.ts index 69d63a9b632..6c0cc872cf0 100644 --- a/packages/shared/watchDebounced/index.ts +++ b/packages/shared/watchDebounced/index.ts @@ -1,4 +1,4 @@ -import type { MaybeRefOrGetter, WatchCallback, WatchOptions, WatchSource, WatchStopHandle } from 'vue' +import type { MaybeRefOrGetter, WatchCallback, WatchHandle, WatchOptions, WatchSource } from 'vue' import type { DebounceFilterOptions, MapOldSources, MapSources } from '../utils' import { debounceFilter } from '../utils' import { watchWithFilter } from '../watchWithFilter' @@ -8,16 +8,16 @@ export interface WatchDebouncedOptions extends WatchOptions[]>, Immediate extends Readonly = false>(sources: [...T], cb: WatchCallback, MapOldSources>, options?: WatchDebouncedOptions): WatchStopHandle -export function watchDebounced = false>(source: WatchSource, cb: WatchCallback, options?: WatchDebouncedOptions): WatchStopHandle -export function watchDebounced = false>(source: T, cb: WatchCallback, options?: WatchDebouncedOptions): WatchStopHandle +export function watchDebounced[]>, Immediate extends Readonly = false>(sources: [...T], cb: WatchCallback, MapOldSources>, options?: WatchDebouncedOptions): WatchHandle +export function watchDebounced = false>(source: WatchSource, cb: WatchCallback, options?: WatchDebouncedOptions): WatchHandle +export function watchDebounced = false>(source: T, cb: WatchCallback, options?: WatchDebouncedOptions): WatchHandle // implementation export function watchDebounced = false>( source: any, cb: any, options: WatchDebouncedOptions = {}, -): WatchStopHandle { +): WatchHandle { const { debounce = 0, maxWait = undefined, diff --git a/packages/shared/watchDeep/index.ts b/packages/shared/watchDeep/index.ts index 0a80cdbb19e..5fe46255987 100644 --- a/packages/shared/watchDeep/index.ts +++ b/packages/shared/watchDeep/index.ts @@ -1,4 +1,4 @@ -import type { WatchCallback, WatchOptions, WatchSource, WatchStopHandle } from 'vue' +import type { WatchCallback, WatchHandle, WatchOptions, WatchSource } from 'vue' import type { MapOldSources, MapSources } from '../utils/types' import { watch } from 'vue' @@ -11,13 +11,13 @@ export function watchDeep< source: [...T], cb: WatchCallback, MapOldSources>, options?: Omit, 'deep'> -): WatchStopHandle +): WatchHandle export function watchDeep = false>( source: WatchSource, cb: WatchCallback, options?: Omit, 'deep'> -): WatchStopHandle +): WatchHandle export function watchDeep< T extends object, @@ -26,7 +26,7 @@ export function watchDeep< source: T, cb: WatchCallback, options?: Omit, 'deep'> -): WatchStopHandle +): WatchHandle /** * Shorthand for watching value with {deep: true} diff --git a/packages/shared/watchImmediate/index.ts b/packages/shared/watchImmediate/index.ts index 1caf4fb86b8..80051e2612a 100644 --- a/packages/shared/watchImmediate/index.ts +++ b/packages/shared/watchImmediate/index.ts @@ -1,4 +1,4 @@ -import type { WatchCallback, WatchOptions, WatchSource, WatchStopHandle } from 'vue' +import type { WatchCallback, WatchHandle, WatchOptions, WatchSource } from 'vue' import type { MapOldSources, MapSources } from '../utils/types' import { watch } from 'vue' @@ -8,19 +8,19 @@ export function watchImmediate[]>>( source: [...T], cb: WatchCallback, MapOldSources>, options?: Omit, 'immediate'> -): WatchStopHandle +): WatchHandle export function watchImmediate( source: WatchSource, cb: WatchCallback, options?: Omit, 'immediate'> -): WatchStopHandle +): WatchHandle export function watchImmediate( source: T, cb: WatchCallback, options?: Omit, 'immediate'> -): WatchStopHandle +): WatchHandle /** * Shorthand for watching value with {immediate: true} diff --git a/packages/shared/watchOnce/index.ts b/packages/shared/watchOnce/index.ts index 0abb9db30fa..debf558325a 100644 --- a/packages/shared/watchOnce/index.ts +++ b/packages/shared/watchOnce/index.ts @@ -1,4 +1,4 @@ -import type { WatchCallback, WatchOptions, WatchSource, WatchStopHandle } from 'vue' +import type { WatchCallback, WatchHandle, WatchOptions, WatchSource } from 'vue' import type { MapOldSources, MapSources } from '../utils' import { watch } from 'vue' @@ -7,19 +7,19 @@ export function watchOnce[]>>( source: [...T], cb: WatchCallback, MapOldSources>, options?: Omit, 'once'> -): WatchStopHandle +): WatchHandle export function watchOnce( source: WatchSource, cb: WatchCallback, options?: Omit, 'once'> -): WatchStopHandle +): WatchHandle export function watchOnce( source: T, cb: WatchCallback, options?: Omit, 'once'> -): WatchStopHandle +): WatchHandle /** * Shorthand for watching value with { once: true } diff --git a/packages/shared/watchThrottled/index.ts b/packages/shared/watchThrottled/index.ts index 4ac43ef4f04..c46245098a6 100644 --- a/packages/shared/watchThrottled/index.ts +++ b/packages/shared/watchThrottled/index.ts @@ -1,4 +1,4 @@ -import type { MaybeRefOrGetter, WatchCallback, WatchOptions, WatchSource, WatchStopHandle } from 'vue' +import type { MaybeRefOrGetter, WatchCallback, WatchHandle, WatchOptions, WatchSource } from 'vue' import type { MapOldSources, MapSources } from '../utils' import { throttleFilter } from '../utils' import { watchWithFilter } from '../watchWithFilter' @@ -10,16 +10,16 @@ export interface WatchThrottledOptions extends WatchOptions[]>, Immediate extends Readonly = false>(sources: [...T], cb: WatchCallback, MapOldSources>, options?: WatchThrottledOptions): WatchStopHandle -export function watchThrottled = false>(source: WatchSource, cb: WatchCallback, options?: WatchThrottledOptions): WatchStopHandle -export function watchThrottled = false>(source: T, cb: WatchCallback, options?: WatchThrottledOptions): WatchStopHandle +export function watchThrottled[]>, Immediate extends Readonly = false>(sources: [...T], cb: WatchCallback, MapOldSources>, options?: WatchThrottledOptions): WatchHandle +export function watchThrottled = false>(source: WatchSource, cb: WatchCallback, options?: WatchThrottledOptions): WatchHandle +export function watchThrottled = false>(source: T, cb: WatchCallback, options?: WatchThrottledOptions): WatchHandle // implementation export function watchThrottled = false>( source: any, cb: any, options: WatchThrottledOptions = {}, -): WatchStopHandle { +): WatchHandle { const { throttle = 0, trailing = true, diff --git a/packages/shared/watchWithFilter/index.ts b/packages/shared/watchWithFilter/index.ts index 5693fda0027..aeac1f04095 100644 --- a/packages/shared/watchWithFilter/index.ts +++ b/packages/shared/watchWithFilter/index.ts @@ -1,4 +1,4 @@ -import type { WatchCallback, WatchOptions, WatchSource, WatchStopHandle } from 'vue' +import type { WatchCallback, WatchHandle, WatchOptions, WatchSource } from 'vue' import type { ConfigurableEventFilter, MapOldSources, MapSources } from '../utils' import { watch } from 'vue' import { bypassFilter, createFilterWrapper } from '../utils' @@ -6,16 +6,16 @@ import { bypassFilter, createFilterWrapper } from '../utils' export interface WatchWithFilterOptions extends WatchOptions, ConfigurableEventFilter {} // overloads -export function watchWithFilter[]>, Immediate extends Readonly = false>(sources: [...T], cb: WatchCallback, MapOldSources>, options?: WatchWithFilterOptions): WatchStopHandle -export function watchWithFilter = false>(source: WatchSource, cb: WatchCallback, options?: WatchWithFilterOptions): WatchStopHandle -export function watchWithFilter = false>(source: T, cb: WatchCallback, options?: WatchWithFilterOptions): WatchStopHandle +export function watchWithFilter[]>, Immediate extends Readonly = false>(sources: [...T], cb: WatchCallback, MapOldSources>, options?: WatchWithFilterOptions): WatchHandle +export function watchWithFilter = false>(source: WatchSource, cb: WatchCallback, options?: WatchWithFilterOptions): WatchHandle +export function watchWithFilter = false>(source: T, cb: WatchCallback, options?: WatchWithFilterOptions): WatchHandle // implementation export function watchWithFilter = false>( source: any, cb: any, options: WatchWithFilterOptions = {}, -): WatchStopHandle { +): WatchHandle { const { eventFilter = bypassFilter, ...watchOptions