docs(debounce): clarify that cancel() drops, never flushes, the trailing call

Markus on PR #629 — the cancel-not-flush contract is what the
PersonMentionEditor onDestroy path relies on. Spell it out so future
callers can rely on the same guarantee.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
Marcel
2026-05-19 22:33:20 +02:00
committed by marcel
parent 2ca512fc9d
commit 4d875e7e67

View File

@@ -1,9 +1,9 @@
/** /**
* Returns a debounced version of fn that delays invocation until after * Returns a debounced version of fn that delays invocation until after
* `delay` ms have elapsed since the last call. The returned function * `delay` ms have elapsed since the last call. The returned function
* exposes a `cancel()` method that clears any pending invocation — * exposes a `cancel()` method that DROPS (does not flush) the pending
* essential when the host context (a destroyed component, an unmounted * trailing invocation — essential when the host context (a destroyed
* editor) shouldn't fire the trailing call. * component, an unmounted editor) shouldn't fire the trailing call.
*/ */
// eslint-disable-next-line @typescript-eslint/no-explicit-any // eslint-disable-next-line @typescript-eslint/no-explicit-any
export function debounce<T extends (...args: any[]) => void>( export function debounce<T extends (...args: any[]) => void>(