Skip to content

useTimeoutPoll ​

Category
Export Size
407 B
Last Changed
last month

Use timeout to poll something. It will trigger callback after last task is done.

Demo ​

Count: 0
isActive: false

Usage ​

ts
import { useTimeoutPoll } from '@vueuse/core'

const count = ref(0)

async function fetchData() {
  await new Promise(resolve => setTimeout(resolve, 1000))
  count.value++
}

// Only trigger after last fetch is done
const { isActive, pause, resume } = useTimeoutPoll(fetchData, 1000)

Type Declarations ​

typescript
export declare function useTimeoutPoll(
  fn: () => Awaitable<void>,
  interval: MaybeRefOrGetter<number>,
  timeoutPollOptions?: UseTimeoutFnOptions,
): Pausable

Source ​

Source • Demo • Docs

Contributors ​

Anthony Fu
Anthony Fu
Sebastien
David Vallejo
jiadesen
sun0day
Jelf
Wenlu Wang

Changelog ​

v12.0.0-beta.1 on 11/21/2024
0a9ed - feat!: drop Vue 2 support, optimize bundles and clean up (#4349)
v10.2.1 on 6/28/2023
7a897 - fix: unexpected immediate execution (#3159)
v10.0.0-beta.4 on 4/13/2023
4d757 - feat(types)!: rename MaybeComputedRef to MaybeRefOrGetter

Released under the MIT License.