UNPKG

@difizen/ai-flow

Version:

Scalable, out-of-the-box, agent-oriented flow

13 lines 412 B
import { debounce } from 'lodash'; import { useLayoutEffect, useMemo, useRef } from 'react'; export function useDebounce(callback, delay) { var callbackRef = useRef(callback); useLayoutEffect(function () { callbackRef.current = callback; }); return useMemo(function () { return debounce(function () { return callbackRef.current.apply(callbackRef, arguments); }, delay); }, [delay]); }