{"version":3,"file":"useDebouncedCallback.cjs","names":["useDebouncer"],"sources":["../../src/debouncer/useDebouncedCallback.ts"],"sourcesContent":["import { useCallback } from 'react'\nimport { useDebouncer } from './useDebouncer'\nimport type { ReactDebouncerOptions } from './useDebouncer'\nimport type { AnyFunction } from '@tanstack/pacer/types'\n\n/**\n * A React hook that creates a debounced version of a callback function.\n * This hook is essentially a wrapper around the basic `debounce` function\n * that is exported from `@tanstack/pacer`,\n * but optimized for React with reactive options and a stable function reference.\n *\n * The debounced function will only execute after the specified wait time has elapsed\n * since its last invocation. If called again before the wait time expires, the timer\n * resets and starts waiting again.\n *\n * This hook provides a simpler API compared to `useDebouncer`, making it ideal for basic\n * debouncing needs. However, it does not expose the underlying Debouncer instance.\n *\n * For advanced usage requiring features like:\n * - Manual cancellation\n * - Access to execution counts\n * - Custom useCallback dependencies\n *\n * Consider using the `useDebouncer` hook instead.\n *\n * @example\n * ```tsx\n * // Debounce a search handler\n * const handleSearch = useDebouncedCallback((query: string) => {\n *   fetchSearchResults(query);\n * }, {\n *   wait: 500 // Wait 500ms between executions\n * });\n *\n * // Use in an input\n * <input\n *   type=\"search\"\n *   onChange={(e) => handleSearch(e.target.value)}\n * />\n * ```\n */\nexport function useDebouncedCallback<TFn extends AnyFunction>(\n  fn: TFn,\n  options: ReactDebouncerOptions<TFn, {}>,\n): (...args: Parameters<TFn>) => void {\n  const debouncedFn = useDebouncer(fn, options).maybeExecute\n  return useCallback((...args) => debouncedFn(...args), [debouncedFn])\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyCA,SAAgB,qBACd,IACA,SACoC;CACpC,MAAM,cAAcA,kCAAa,IAAI,QAAQ,CAAC;AAC9C,gCAAoB,GAAG,SAAS,YAAY,GAAG,KAAK,EAAE,CAAC,YAAY,CAAC"}