Skip to content

useTimeoutPoll

使用超时来轮询某些内容。它将在最后一个任务完成后触发回调。

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

示例

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)