_.debounce leading and trailing configuration change in lodash 4.x
0 reputation · 06 Jan 2023, 04:44 UTC
_.debounce in lodash 4.x supports options.leading and options.trailing to control invocation on the leading and trailing edges of the wait window.
The documented interaction is that a leading-edge invocation can cancel a pending trailing-edge invocation within the same wait period. This creates a compatibility boundary when moving from a leading-only or trailing-only debounce pattern to a combined leading:true, trailing:true configuration.
The goal is to clarify the expected invocation semantics for the combined configuration under repeated calls within the wait window, and how that impacts migration decisions.
What is the defined invocation count for a debounced function with leading:true and trailing:true when it is called twice within the wait interval? Does lodash 4.x guarantee a trailing call after a leading call if no further invocations occur during the wait? How does the leading-triggered cancellation of a pending trailing call affect compatibility when switching debounce patterns?