radash icon indicating copy to clipboard operation
radash copied to clipboard

allow debounce to trigger on leading (and trailing) edge

Open mkresse opened this issue 1 year ago • 3 comments

Hello,

I would like to propose a feature enhancement for the debounce() function. Currently, debounce() only triggers on the trailing edge. However, in certain use cases, it would be beneficial to have the option to also trigger on the leading edge. This enhancement could significantly improve the perceived performance of an application using this function, as on the start of a series of user actions, an immediate feedback can be given.

The expected behavior would be similar to the debounce implementation in lodash, where both the leading and trailing options are set to true (see "Note" on documentation). This would provide more flexibility and control over the function's behavior, allowing developers to better tailor the function to their specific needs.

Thank you for considering this feature request. I believe this enhancement would be a valuable addition to the radash library.

Best regards.

mkresse avatar May 22 '24 08:05 mkresse

Looks like @LynnSha1ng has implemented this in #387. We'd appreciate this improvement over at radashi-org/radashi if anyone wants to transfer it over. :)

aleclarson avatar Jun 28 '24 18:06 aleclarson

@aleclarson I took a stab at this, although with falling edge option for throttle instead:

  • https://github.com/radashi-org/radashi/pull/128
  • https://github.com/radashi-org/radashi/pull/127

crishoj avatar Jul 21 '24 12:07 crishoj

same issue +1

lake2 avatar Jul 31 '24 10:07 lake2

same issue +1

I urgently need this parameter !!!

nicolas-tesla-x avatar Jul 14 '25 04:07 nicolas-tesla-x

@nicolas-tesla-x debounce has a leading parameter.

If this is not sufficient for your needs, could you please give an example?

crishoj avatar Jul 14 '25 09:07 crishoj