Skip to content
On this page

Polling

By setting options.pollingInterval, enter the polling mode, useRequest will periodically trigger service execution.

Code demonstration

Return

PropertyDescriptionType
runStart polling(...params: TParams) => void
runAsyncStart polling(...params: TParams) => Promise<TData>
cancelStop polling() => void

Options

PropertyDescriptionTypeDefault
pollingIntervalPolling interval, in milliseconds. If the value is greater than 0, the polling mode is activated.number|Ref<number>0
pollingWhenHiddenWhether to continue polling when the page is hidden. If set to false, polling will be temporarily paused when the page is hidden, and resume when the page is visible again.booleantrue
pollingErrorRetryCountNumber of polling error retries. If set to -1, an infinite number of timesnumber-1

Remark

  • options.pollingInterval support dynamic changes.
  • options.pollingWhenHidden support dynamic changes.
  • If you set options.manual = true, the initialization will not start polling, you need start it by run/runAsync.
  • The polling logic is to wait for pollingInterval time after each request is completed, and then initiate the next request.

Source

SourceDocsDemo