mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-04-27 07:48:01 -07:00
* refactor dexie services for future schema updates Co-authored-by: Jeremy Letto <jeremy.letto@datasite.com>
13 lines
358 B
TypeScript
13 lines
358 B
TypeScript
import { useCallback } from 'react';
|
|
import { debounce, DebouncedFunc } from 'lodash';
|
|
|
|
type UseDebounceType = (...args: any) => any;
|
|
const DEBOUNCE_DELAY = 250;
|
|
|
|
export function useDebounce<T extends UseDebounceType>(
|
|
fn: T,
|
|
deps: any[] = [],
|
|
timeout: number = DEBOUNCE_DELAY
|
|
): DebouncedFunc<T> {
|
|
return useCallback(debounce(fn, timeout), deps);
|
|
}
|