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

Function throttleStrategy

packages/db/src/strategies/throttleStrategy.ts:48–68  ·  view source on GitHub ↗
(
  options: ThrottleStrategyOptions,
)

Source from the content-addressed store, hash-verified

46 * ```
47 */
48export function throttleStrategy(
49 options: ThrottleStrategyOptions,
50): ThrottleStrategy {
51 const throttler = new LiteThrottler(
52 (callback: () => Transaction) => callback(),
53 options,
54 )
55
56 return {
57 _type: `throttle`,
58 options,
59 execute: <T extends object = Record<string, unknown>>(
60 fn: () => Transaction<T>,
61 ) => {
62 throttler.maybeExecute(fn as () => Transaction)
63 },
64 cleanup: () => {
65 throttler.cancel()
66 },
67 }
68}

Callers 3

AppFunction · 0.85

Calls 1

cancelMethod · 0.80

Tested by

no test coverage detected