fponticelli / thx.core

Super-charged standard library for Haxe.
http://thx-lib.org
MIT License
124 stars 43 forks source link

Issues with Timer.throttle and Timer.debounce functions? #263

Closed zabojad closed 5 years ago

zabojad commented 5 years ago

I'm trying to use the Timer.debounce and Timer.throttle functions. I'm facing several issues:

1- The throttle and debounce functions do not allow arguments for the callback function, unlike its lodash counterpart...

2- the debounce leading option implementation is faulty as far as I understand it. IMO, it should execute the callback function immediately and not allow any further execution of the callback during the delayms time... Instead, it executes the callback immediately once and then again at the end of the delay...

Here is a description of how it should behave.

3- the throttle implementation never reset the waiting flag to false, making it never callable again even after delayms...

zabojad commented 5 years ago

OK, I ended up using this instead which does a better job for debouncing and throttling.