Skip to content

feat(watch): update watch return typo in watchExtractedObservable, watchDebounced, watchDeep, watchImmediate, watchOnce, watchThrottled and watchWithFilter #4896

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
feat(watch): update watch return typo
  • Loading branch information
ArthurDarkstone committed Jul 21, 2025
commit da47f891437abaff97bd4e84a54e6b027b59135a
2 changes: 1 addition & 1 deletion packages/guidelines.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export function watchDebounced(
source: any,
cb: any,
options: WatchDebouncedOptions = {},
): WatchStopHandle {
): WatchHandle {
return watch(
source,
() => { /* ... */ },
Expand Down
12 changes: 6 additions & 6 deletions packages/rxjs/watchExtractedObservable/index.ts
Original file line number Diff line number Diff line change
@@ -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'

Expand All @@ -27,7 +27,7 @@ export function watchExtractedObservable<
callback: (snapshot: E) => void,
subscriptionOptions?: WatchExtractedObservableOptions,
watchOptions?: WatchOptions<Immediate>
): WatchStopHandle
): WatchHandle

// overload: multiple sources w/ `as const`
// watch([foo, bar] as const, () => {})
Expand All @@ -46,7 +46,7 @@ export function watchExtractedObservable<
callback: (snapshot: E) => void,
subscriptionOptions?: WatchExtractedObservableOptions,
watchOptions?: WatchOptions<Immediate>
): WatchStopHandle
): WatchHandle

// overload: single source + cb
export function watchExtractedObservable<
Expand All @@ -63,7 +63,7 @@ export function watchExtractedObservable<
callback: (snapshot: E) => void,
subscriptionOptions?: WatchExtractedObservableOptions,
watchOptions?: WatchOptions<Immediate>
): WatchStopHandle
): WatchHandle

// overload: watching reactive object w/ cb
export function watchExtractedObservable<
Expand All @@ -80,7 +80,7 @@ export function watchExtractedObservable<
callback: (snapshot: E) => void,
subscriptionOptions?: WatchExtractedObservableOptions,
watchOptions?: WatchOptions<Immediate>
): WatchStopHandle
): WatchHandle

// implementation
export function watchExtractedObservable<T = any, E = unknown, Immediate extends Readonly<boolean> = false>(
Expand All @@ -89,7 +89,7 @@ export function watchExtractedObservable<T = any, E = unknown, Immediate extends
callback: (snapshot: E) => void,
subscriptionOptions?: WatchExtractedObservableOptions,
watchOptions?: WatchOptions<Immediate>,
): WatchStopHandle {
): WatchHandle {
let subscription: Subscription | undefined

tryOnScopeDispose(() => {
Expand Down
10 changes: 5 additions & 5 deletions packages/shared/watchDebounced/index.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -8,16 +8,16 @@ export interface WatchDebouncedOptions<Immediate> extends WatchOptions<Immediate
}

// overloads
export function watchDebounced<T extends Readonly<WatchSource<unknown>[]>, Immediate extends Readonly<boolean> = false>(sources: [...T], cb: WatchCallback<MapSources<T>, MapOldSources<T, Immediate>>, options?: WatchDebouncedOptions<Immediate>): WatchStopHandle
export function watchDebounced<T, Immediate extends Readonly<boolean> = false>(source: WatchSource<T>, cb: WatchCallback<T, Immediate extends true ? T | undefined : T>, options?: WatchDebouncedOptions<Immediate>): WatchStopHandle
export function watchDebounced<T extends object, Immediate extends Readonly<boolean> = false>(source: T, cb: WatchCallback<T, Immediate extends true ? T | undefined : T>, options?: WatchDebouncedOptions<Immediate>): WatchStopHandle
export function watchDebounced<T extends Readonly<WatchSource<unknown>[]>, Immediate extends Readonly<boolean> = false>(sources: [...T], cb: WatchCallback<MapSources<T>, MapOldSources<T, Immediate>>, options?: WatchDebouncedOptions<Immediate>): WatchHandle
export function watchDebounced<T, Immediate extends Readonly<boolean> = false>(source: WatchSource<T>, cb: WatchCallback<T, Immediate extends true ? T | undefined : T>, options?: WatchDebouncedOptions<Immediate>): WatchHandle
export function watchDebounced<T extends object, Immediate extends Readonly<boolean> = false>(source: T, cb: WatchCallback<T, Immediate extends true ? T | undefined : T>, options?: WatchDebouncedOptions<Immediate>): WatchHandle

// implementation
export function watchDebounced<Immediate extends Readonly<boolean> = false>(
source: any,
cb: any,
options: WatchDebouncedOptions<Immediate> = {},
): WatchStopHandle {
): WatchHandle {
const {
debounce = 0,
maxWait = undefined,
Expand Down
8 changes: 4 additions & 4 deletions packages/shared/watchDeep/index.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -11,13 +11,13 @@ export function watchDeep<
source: [...T],
cb: WatchCallback<MapSources<T>, MapOldSources<T, Immediate>>,
options?: Omit<WatchOptions<Immediate>, 'deep'>
): WatchStopHandle
): WatchHandle

export function watchDeep<T, Immediate extends Readonly<boolean> = false>(
source: WatchSource<T>,
cb: WatchCallback<T, Immediate extends true ? T | undefined : T>,
options?: Omit<WatchOptions<Immediate>, 'deep'>
): WatchStopHandle
): WatchHandle

export function watchDeep<
T extends object,
Expand All @@ -26,7 +26,7 @@ export function watchDeep<
source: T,
cb: WatchCallback<T, Immediate extends true ? T | undefined : T>,
options?: Omit<WatchOptions<Immediate>, 'deep'>
): WatchStopHandle
): WatchHandle

/**
* Shorthand for watching value with {deep: true}
Expand Down
8 changes: 4 additions & 4 deletions packages/shared/watchImmediate/index.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -8,19 +8,19 @@ export function watchImmediate<T extends Readonly<WatchSource<unknown>[]>>(
source: [...T],
cb: WatchCallback<MapSources<T>, MapOldSources<T, true>>,
options?: Omit<WatchOptions<true>, 'immediate'>
): WatchStopHandle
): WatchHandle

export function watchImmediate<T>(
source: WatchSource<T>,
cb: WatchCallback<T, T | undefined>,
options?: Omit<WatchOptions<true>, 'immediate'>
): WatchStopHandle
): WatchHandle

export function watchImmediate<T extends object>(
source: T,
cb: WatchCallback<T, T | undefined>,
options?: Omit<WatchOptions<true>, 'immediate'>
): WatchStopHandle
): WatchHandle

/**
* Shorthand for watching value with {immediate: true}
Expand Down
8 changes: 4 additions & 4 deletions packages/shared/watchOnce/index.ts
Original file line number Diff line number Diff line change
@@ -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'

Expand All @@ -7,19 +7,19 @@ export function watchOnce<T extends Readonly<WatchSource<unknown>[]>>(
source: [...T],
cb: WatchCallback<MapSources<T>, MapOldSources<T, true>>,
options?: Omit<WatchOptions<true>, 'once'>
): WatchStopHandle
): WatchHandle

export function watchOnce<T>(
source: WatchSource<T>,
cb: WatchCallback<T, T | undefined>,
options?: Omit<WatchOptions<true>, 'once'>
): WatchStopHandle
): WatchHandle

export function watchOnce<T extends object>(
source: T,
cb: WatchCallback<T, T | undefined>,
options?: Omit<WatchOptions<true>, 'once'>
): WatchStopHandle
): WatchHandle

/**
* Shorthand for watching value with { once: true }
Expand Down
10 changes: 5 additions & 5 deletions packages/shared/watchThrottled/index.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -10,16 +10,16 @@ export interface WatchThrottledOptions<Immediate> extends WatchOptions<Immediate
}

// overloads
export function watchThrottled<T extends Readonly<WatchSource<unknown>[]>, Immediate extends Readonly<boolean> = false>(sources: [...T], cb: WatchCallback<MapSources<T>, MapOldSources<T, Immediate>>, options?: WatchThrottledOptions<Immediate>): WatchStopHandle
export function watchThrottled<T, Immediate extends Readonly<boolean> = false>(source: WatchSource<T>, cb: WatchCallback<T, Immediate extends true ? T | undefined : T>, options?: WatchThrottledOptions<Immediate>): WatchStopHandle
export function watchThrottled<T extends object, Immediate extends Readonly<boolean> = false>(source: T, cb: WatchCallback<T, Immediate extends true ? T | undefined : T>, options?: WatchThrottledOptions<Immediate>): WatchStopHandle
export function watchThrottled<T extends Readonly<WatchSource<unknown>[]>, Immediate extends Readonly<boolean> = false>(sources: [...T], cb: WatchCallback<MapSources<T>, MapOldSources<T, Immediate>>, options?: WatchThrottledOptions<Immediate>): WatchHandle
export function watchThrottled<T, Immediate extends Readonly<boolean> = false>(source: WatchSource<T>, cb: WatchCallback<T, Immediate extends true ? T | undefined : T>, options?: WatchThrottledOptions<Immediate>): WatchHandle
export function watchThrottled<T extends object, Immediate extends Readonly<boolean> = false>(source: T, cb: WatchCallback<T, Immediate extends true ? T | undefined : T>, options?: WatchThrottledOptions<Immediate>): WatchHandle

// implementation
export function watchThrottled<Immediate extends Readonly<boolean> = false>(
source: any,
cb: any,
options: WatchThrottledOptions<Immediate> = {},
): WatchStopHandle {
): WatchHandle {
const {
throttle = 0,
trailing = true,
Expand Down
10 changes: 5 additions & 5 deletions packages/shared/watchWithFilter/index.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
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'

export interface WatchWithFilterOptions<Immediate> extends WatchOptions<Immediate>, ConfigurableEventFilter {}

// overloads
export function watchWithFilter<T extends Readonly<WatchSource<unknown>[]>, Immediate extends Readonly<boolean> = false>(sources: [...T], cb: WatchCallback<MapSources<T>, MapOldSources<T, Immediate>>, options?: WatchWithFilterOptions<Immediate>): WatchStopHandle
export function watchWithFilter<T, Immediate extends Readonly<boolean> = false>(source: WatchSource<T>, cb: WatchCallback<T, Immediate extends true ? T | undefined : T>, options?: WatchWithFilterOptions<Immediate>): WatchStopHandle
export function watchWithFilter<T extends object, Immediate extends Readonly<boolean> = false>(source: T, cb: WatchCallback<T, Immediate extends true ? T | undefined : T>, options?: WatchWithFilterOptions<Immediate>): WatchStopHandle
export function watchWithFilter<T extends Readonly<WatchSource<unknown>[]>, Immediate extends Readonly<boolean> = false>(sources: [...T], cb: WatchCallback<MapSources<T>, MapOldSources<T, Immediate>>, options?: WatchWithFilterOptions<Immediate>): WatchHandle
export function watchWithFilter<T, Immediate extends Readonly<boolean> = false>(source: WatchSource<T>, cb: WatchCallback<T, Immediate extends true ? T | undefined : T>, options?: WatchWithFilterOptions<Immediate>): WatchHandle
export function watchWithFilter<T extends object, Immediate extends Readonly<boolean> = false>(source: T, cb: WatchCallback<T, Immediate extends true ? T | undefined : T>, options?: WatchWithFilterOptions<Immediate>): WatchHandle

// implementation
export function watchWithFilter<Immediate extends Readonly<boolean> = false>(
source: any,
cb: any,
options: WatchWithFilterOptions<Immediate> = {},
): WatchStopHandle {
): WatchHandle {
const {
eventFilter = bypassFilter,
...watchOptions
Expand Down
Loading
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy