UNPKG

vuestic-ui

Version:
32 lines (31 loc) 1.28 kB
/** * @description returns throttled function or value * the last one always returns last-call value in the end if no more new calls were provided * @example * import { useThrottleFunction, useThrottleValue } from '../../composables' * ... * const localThrottledFunction = useThrottleFunction(functionToThrottle, props) * const localThrottledValue = useThrottleValue(reactiveValueToThrottle, props) */ import { Ref, ExtractPropTypes } from 'vue'; type ThrottledFunctionArgs = any[]; type ThrottledFunction<Output> = (...args: ThrottledFunctionArgs) => Output; export declare const useThrottleProps: { delay: { type: NumberConstructor; default: number; validator: (value: number) => boolean; }; }; type UseThrottleProps = ExtractPropTypes<typeof useThrottleProps>; /** * @param fn passed function to throttle * @param props { delay } call delay in ms */ export declare function useThrottleFunction<Output>(fn: ThrottledFunction<Output>, props: UseThrottleProps): (this: any, ...args: ThrottledFunctionArgs) => Output; /** * @param value passed reactive value to throttle * @param props { delay } call delay in ms */ export declare function useThrottleValue<T>(value: Ref<T>, props: UseThrottleProps): Ref<T>; export {};