跳转到内容

Debounce

Debounce delays execution of a high-frequency operation, only executing the last trigger within a time window.

debounceRun is a debounced version of run, with a default wait time of 500ms.

typescript
const useApi = createRequest({ dataKey: 'data' })

const { debounceRun } = useApi(searchService, {
  debounceWait: 300,
})

API

PropertyTypeDefaultDescription
debounceWaitMaybeRef<number>500Debounce wait time (ms)
debounceMaxWaitMaybeRef<number>-Maximum delay allowed
debounceLeadingMaybeRef<boolean>falseExecute before delay starts
debounceTrailingMaybeRef<boolean>trueExecute after delay ends