-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
/
index.ts
39 lines (34 loc) · 1.05 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import type { WatchCallback, WatchOptions, WatchSource, WatchStopHandle } from 'vue-demi'
import { watch } from 'vue-demi'
import type { MapOldSources, MapSources, MultiWatchSources } from '../utils/types'
// overloads
export function watchImmediate<T extends Readonly<MultiWatchSources>>(
source: T,
cb: WatchCallback<MapSources<T>, MapOldSources<T, true>>,
options?: Omit<WatchOptions<true>, 'deep'>
): WatchStopHandle
export function watchImmediate<T>(
source: WatchSource<T>,
cb: WatchCallback<T, T | undefined>,
options?: Omit<WatchOptions<true>, 'deep'>
): WatchStopHandle
export function watchImmediate<T extends object>(
source: T,
cb: WatchCallback<T, T | undefined>,
options?: Omit<WatchOptions<true>, 'deep'>
): WatchStopHandle
/**
* Shorthand for watching value with {immediate: true}
*
* @see https://vueuse.org/watchImmediate
*/
export function watchImmediate<T = any>(source: T, cb: any, options?: Omit<WatchOptions, 'immediate'>) {
return watch(
source as any,
cb,
{
...options,
immediate: true,
},
)
}