Appearance
usePolling
一个管理轮询的 Hook
Demo
</>
count: 0
自动轮询
count: 0
手动轮询
Usage
import { usePolling } from 'v3-use'
const { polling, initPolling } = usePolling()
import { usePolling } from 'v3-use'
const { polling, initPolling } = usePolling()
Reference
Type Declarations
export interface Options {
manual?: boolean
immediate?: boolean
}
export declare type Polling = Ref<IntervalActions | null>
export declare function usePolling(): {
polling: Polling
initPolling: (fn: () => void, interval: number, options?: Options) => void
}
export interface Options {
manual?: boolean
immediate?: boolean
}
export declare type Polling = Ref<IntervalActions | null>
export declare function usePolling(): {
polling: Polling
initPolling: (fn: () => void, interval: number, options?: Options) => void
}
Params
Result
polling
: Polling
— 轮询控制器initPolling
: (fn: () => void, interval: number, options?: Options) => void
— 初始化轮询函数