useTimeoutPoll
使用超时来轮询某些内容。在最后一个任务完成后触发回调。
示例
Count: 0
isActive: false
用法
ts
import { useTimeoutPoll } from '@vueuse/core'
const count = ref(0)
async function fetchData() {
await new Promise(resolve => setTimeout(resolve, 1000))
count.value++
}
// 仅在最后一个获取完成后触发
const { isActive, pause, resume } = useTimeoutPoll(fetchData, 1000)
类型声明
typescript
export declare function useTimeoutPoll(
fn: () => Awaitable<void>,
interval: MaybeRefOrGetter<number>,
options?: UseTimeoutFnOptions,
): Pausable
源码
贡献者
Anthony Fu
一纸忘忧
Anthony Fu
Hongkun
OrbisK
Sebastien
David Vallejo
jiadesen
sun0day
Jelf
Wenlu Wang
更新日志
v12.3.0
on 1/2/2025a5fb0
- fix: only start by default at clientv12.0.0-beta.1
on 11/21/2024v10.2.1
on 6/28/2023v10.0.0-beta.4
on 4/13/20234d757
- feat(types)!: rename MaybeComputedRef
to MaybeRefOrGetter