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/watchOnce.md
1---2category: Watch3---45# watchOnce67Shorthand for watching value with `{ once: true }`. Once the callback fires once, the watcher will be stopped.8See [Vue's docs](https://vuejs.org/guide/essentials/watchers.html#once-watchers) for full details.910## Usage1112Similar to `watch`, but with `{ once: true }`1314```ts15import { watchOnce } from '@vueuse/core'1617watchOnce(source, () => {18// triggers only once19console.log('source changed!')20})21```2223## Type Declarations2425```ts26export declare function watchOnce<T extends Readonly<MultiWatchSources>>(27source: [...T],28cb: WatchCallback<MapSources<T>, MapOldSources<T, true>>,29options?: Omit<WatchOptions<true>, "once">,30): WatchHandle31export declare function watchOnce<T>(32source: WatchSource<T>,33cb: WatchCallback<T, T | undefined>,34options?: Omit<WatchOptions<true>, "once">,35): WatchHandle36export declare function watchOnce<T extends object>(37source: T,38cb: WatchCallback<T, T | undefined>,39options?: Omit<WatchOptions<true>, "once">,40): WatchHandle41```42