UNPKG

@tanstack/db

Version:

A reactive client store for building super fast apps on sync

32 lines (31 loc) • 718 B
import { LiteDebouncer } from "@tanstack/pacer-lite/lite-debouncer"; function debounceStrategy(options) { const trailing = options.trailing ?? true; const debouncer = new LiteDebouncer( (callback) => callback(), { ...options, leading: options.leading ?? false, trailing } ); return { _type: `debounce`, options, execute: (fn) => { const execution = { happened: false }; debouncer.maybeExecute(() => { execution.happened = true; return fn(); }); if (!trailing && !execution.happened) return false; return; }, cleanup: () => { } }; } export { debounceStrategy }; //# sourceMappingURL=debounceStrategy.js.map