@aotearoan/neon
Version:
Neon is a lightweight design library of Vue 3 components with minimal dependencies.
25 lines (24 loc) • 1.15 kB
TypeScript
/**
* Debounce utility used for debouncing user input. This has the benefit of also providing a global default which can
* also be set to 0 for improving test code (no need to wait for input). The default debounce timeout is set to 300ms.
*/
export declare class NeonDebounceUtils {
private static debounceTimeout;
/**
* Set a global debounce timeout value. NOTE: Set this to 0 to disable debounce & receive all input events immediately.
* This is useful for testing purposes.
*
* @param debounceTimeout The debounce timeout in milliseconds.
*/
static setGlobalDebounceTimeout(debounceTimeout: number): void;
/**
* Debounce a function, i.e. prevent triggering the function until a certain amount of time has passed without further
* input.
*
* @param fn Function to debounce.
* @param timeout Debounce timeout in milliseconds, uses the global setting by default.
*
* @returns Debounced function or in the case the timeout is set to 0 the original function parameter.
*/
static debounce(fn: (...args: any[]) => void, timeout?: number): (...args: any[]) => void;
}