obsidian/functions/debounce
Mock of Obsidian’s debounce, implemented on real timers.
Functions
Section titled “Functions”| Function | Description |
|---|---|
| debounce | Creates a debounced function that delays calling callback until timeout milliseconds have passed since the first pending call. Each call replaces the pending this and arguments, so the callback always runs with the latest ones. The returned debouncer also has cancel(), which clears the pending timer, and run(), which calls callback at once when a call is pending. As in Obsidian, a call made while one is pending never schedules a second timer. With resetTimer, it pushes the deadline back to timeout milliseconds after that call instead. The mock schedules with setTimeout and reads Date.now(), so tests can drive it with fake timers. Obsidian also reschedules a pending timer when the active window changes; the mock has one window, so it does not. |