useTimeoutPoll 


 Category 
Utilities


 Export Size 
1.02 kB


 Last Changed 
4 months ago


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

import { useTimeoutPoll } from '@vueuse/core'

const count = ref(0)

const fetchData = async () => {
  await promiseTimeout(1000)
  count.value++
}

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

Type Declarations 

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

Source 
Source • Demo • Docs

    
{'path': 'public/docs/vueuse/core/usetimeoutpoll/index.html', 'source': 'DevDocs.IO'}