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/useTimeoutPoll.md
1---2category: Utilities3---45# useTimeoutPoll67Use timeout to poll something. It will trigger callback after last task is done.89## Usage1011```ts12import { useTimeoutPoll } from '@vueuse/core'1314const count = ref(0)1516async function fetchData() {17await new Promise(resolve => setTimeout(resolve, 1000))18count.value++19}2021// Only trigger after last fetch is done22const { isActive, pause, resume } = useTimeoutPoll(fetchData, 1000)23```2425## Type Declarations2627```ts28export interface UseTimeoutPollOptions {29/**30* Start the timer immediately31*32* @default true33*/34immediate?: boolean35/**36* Execute the callback immediately after calling `resume`37*38* @default false39*/40immediateCallback?: boolean41}42export declare function useTimeoutPoll(43fn: () => Awaitable<void>,44interval: MaybeRefOrGetter<number>,45options?: UseTimeoutFnOptions,46): Pausable47```48