MCPcopy Create free account
hub / github.com/TanStack/db / debounceStrategy

Function debounceStrategy

packages/db/src/strategies/debounceStrategy.ts:28–48  ·  view source on GitHub ↗
(
  options: DebounceStrategyOptions,
)

Source from the content-addressed store, hash-verified

26 * ```
27 */
28export function debounceStrategy(
29 options: DebounceStrategyOptions,
30): DebounceStrategy {
31 const debouncer = new LiteDebouncer(
32 (callback: () => Transaction) => callback(),
33 options,
34 )
35
36 return {
37 _type: `debounce`,
38 options,
39 execute: <T extends object = Record<string, unknown>>(
40 fn: () => Transaction<T>,
41 ) => {
42 debouncer.maybeExecute(fn as () => Transaction)
43 },
44 cleanup: () => {
45 debouncer.cancel()
46 },
47 }
48}

Callers 6

useCustomHookFunction · 0.90
useDebouncedTransactionFunction · 0.90
TodoAppFunction · 0.85
AppFunction · 0.85

Calls 1

cancelMethod · 0.80

Tested by 2

useCustomHookFunction · 0.72
useDebouncedTransactionFunction · 0.72