Debounce ​
Enter the debounce mode by setting options.debounceWait. At this time, if run or runAsync is triggered frequently, the request will be executed with the debounce strategy.
Code demonstration ​
Options ​
The usage and effect of all debounce property are the same as lodash-es.debounce
| Property | Description | Type | Default Value |
|---|---|---|---|
| debounceWait | Debounce delay time, in milliseconds. After setting, enter the debounce mode | number | - |
| debounceLeading | Execute the request before the delay starts | boolean|Ref<boolean> | false |
| debounceTrailing | Execute the request after the delay ends | boolean|Ref<boolean> | true |
| debounceMaxWait | The maximum time request is allowed to be delayed before it’s executed | number|Ref<number> | - |
Remark
options.debounceLeadingsupport dynamic changes.options.debounceTrailingsupport dynamic changes.options.debounceMaxWaitsupport dynamic changes.runAsyncwill return aPromisewhen it is actually executed. When it is not executed, there will be no return.cancelcan abort a function waiting to be executed.