Skip to content

Throttle ​

useRequest It provides a options.throttleWait parameter into throttling mode, and if the run or the runAsync is frequently triggered, the request is made by throttling policy.

Basic usage ​

Options ​

The usage and effects of all throttle property are the same as lodash-es.throttle

PropertyDescriptionTypeDefault Value
throttleWaitThrottle wait time, in milliseconds. After setting, enter the throttle modenumber-
throttleLeadingExecute the request before throttling startsboolean|Ref<boolean>true
throttleTrailingExecute the request after throttling endsboolean|Ref<boolean>true

Remark

  • options.throttleWait support dynamic changes.
  • options.throttleLeading support dynamic changes.
  • options.throttleTrailing support dynamic changes.
  • runAsync will return a Promise when it is actually executed. When it is not executed, there will be no return.
  • cancel can abort a function waiting to be executed.

Source ​

Source · Document · Demo

Released under the MIT License.