Category | Reactivity |
---|---|
Export Size | 458 B |
Last Changed | last year |
Alias |
useThrottle throttledRef
|
Related | useThrottleFn |
Throttle changing of a ref value.
import { refThrottled } from '@vueuse/core' const input = ref('') const throttled = refThrottled(input, 1000)
If you don't want to watch trailing changes, set 3rd param false
(it's true
by default):
import { refThrottled } from '@vueuse/core' const input = ref('') const throttled = refThrottled(input, 1000, false)
Allows the callback to be invoked immediately (on the leading edge of the ms
timeout). If you don't want this behavior, set the 4th param false
(it's true
by default):
import { refThrottled } from '@vueuse/core' const input = ref('') const throttled = refThrottled(input, 1000, undefined, false)
/** * Throttle execution of a function. Especially useful for rate limiting * execution of handlers on events like resize and scroll. * * @param value Ref value to be watched with throttle effect * @param delay A zero-or-greater delay in milliseconds. For event callbacks, values around 100 or 250 (or even higher) are most useful. * @param [trailing=true] if true, update the value again after the delay time is up * @param [leading=true] if true, update the value on the leading edge of the ms timeout */ export declare function refThrottled<T>( value: Ref<T>, delay?: number, trailing?: boolean, leading?: boolean ): Ref<T> export { refThrottled as useThrottle, refThrottled as throttledRef }
© 2019-present Anthony Fu
Licensed under the MIT License.
https://vueuse.org/shared/refThrottled/