Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Apply VueUse composables in Vue 3/Nuxt projects to replace custom implementations with battle-tested utilities.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
references/watchAtMost.md
1---2category: Watch3---45# watchAtMost67`watch` with the number of times triggered.89## Usage1011Similar to `watch` with an extra option `count` which set up the number of times the callback function is triggered. After the count is reached, the watch will be stopped automatically.1213```ts14import { watchAtMost } from '@vueuse/core'1516watchAtMost(17source,18() => { console.log('trigger!') }, // triggered it at most 3 times19{20count: 3, // the number of times triggered21},22)23```2425## Type Declarations2627```ts28export interface WatchAtMostOptions<29Immediate,30> extends WatchWithFilterOptions<Immediate> {31count: MaybeRefOrGetter<number>32}33export interface WatchAtMostReturn {34stop: WatchStopHandle35pause: () => void36resume: () => void37count: ShallowRef<number>38}39export declare function watchAtMost<40T extends Readonly<MultiWatchSources>,41Immediate extends Readonly<boolean> = false,42>(43sources: [...T],44cb: WatchCallback<MapSources<T>, MapOldSources<T, Immediate>>,45options: WatchAtMostOptions<Immediate>,46): WatchAtMostReturn47export declare function watchAtMost<48T,49Immediate extends Readonly<boolean> = false,50>(51sources: WatchSource<T>,52cb: WatchCallback<T, Immediate extends true ? T | undefined : T>,53options: WatchAtMostOptions<Immediate>,54): WatchAtMostReturn55```56