跳转到内容

Throttle

Throttle limits a function to execute at most once within a time interval, useful for controlling event frequency.

throttleRun is a throttled version of run, with a default wait time of 500ms.

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

const { throttleRun } = useApi(clickService, {
  throttleWait: 500,
})

API

PropertyTypeDefaultDescription
throttleWaitMaybeRef<number>500Throttle wait time (ms)
throttleLeadingMaybeRef<boolean>trueExecute before throttle starts
throttleTrailingMaybeRef<boolean>trueExecute after throttle ends