Skip to content

useTimeoutPoll

Category
Export Size
407 B
Last Changed
last month

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

Demo

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>,
  timeoutPollOptions?: UseTimeoutFnOptions,
): Pausable

Source

SourceDemoDocs

贡献者

Anthony Fu
丶远方
Anthony Fu
Sebastien
David Vallejo
jiadesen
sun0day
Jelf
Wenlu Wang

变更日志

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.