UNPKG

@better-hooks/performance

Version:
63 lines (48 loc) 2.49 kB
import * as react from 'react'; import { useEffect } from 'react'; declare const useDebounce: (props?: UseDebounceProps) => UseDebounceReturnType; declare type DebounceType = ReturnType<typeof setTimeout> | null; declare type DebounceFunctionType = (callback: () => void | Promise<void>, dynamicDelay?: number) => void; declare type UseDebounceReturnType = { debounce: DebounceFunctionType; reset: VoidFunction; active: boolean; }; declare type UseDebounceProps = { delay?: number; }; declare const useDebounceEffect: (callback: () => void, props: UseDebounceProps, dependencies: any[]) => void; declare const useDebounceState: <T>(initialValue: T, props?: UseDebounceProps) => readonly [T, (newValue: react.SetStateAction<T>) => void]; declare const useDeepEffect: (callback: VoidFunction | (() => VoidFunction), dependencies: any[]) => void; declare const useInterval: (callback: () => void, interval: number | null, options?: UseIntervalOptions) => { active: boolean; start: () => void; stop: () => void; }; declare type UseIntervalOptions = { immediate?: boolean; disabled?: boolean; }; declare const useThrottle: (props?: UseThrottleProps) => UseThrottleReturnType; declare type ThrottleType = ReturnType<typeof setTimeout> | null; declare type ThrottleFunctionType = (callback: () => void | Promise<void>, dynamicProps?: UseThrottleProps) => void; declare type UseThrottleReturnType = { throttle: ThrottleFunctionType; reset: VoidFunction; active: boolean; }; declare type UseThrottleProps = { /** * Execution interval time for triggering callback */ interval?: number; /** * Callback timeout when throttling stops triggering */ timeout?: number | false; }; declare const useThrottleEffect: (callback: () => void, props: UseThrottleProps, dependencies: any[]) => void; declare const useThrottleState: <T>(initialValue: T, props: UseThrottleProps) => readonly [T, (newValue: react.SetStateAction<T>) => void]; declare const useTimeout: (callback: () => void, timeout: number | null) => void; declare const useIsomorphicEffect: typeof useEffect; export { DebounceFunctionType, DebounceType, ThrottleFunctionType, ThrottleType, UseDebounceProps, UseDebounceReturnType, UseIntervalOptions, UseThrottleProps, UseThrottleReturnType, useDebounce, useDebounceEffect, useDebounceState, useDeepEffect, useInterval, useIsomorphicEffect, useThrottle, useThrottleEffect, useThrottleState, useTimeout };