Throttling is a straightforward reduction of the trigger rate. It will cause the event listener to ignore some portion of the events while still firing the listeners at a constant (but reduced) rate.
Unlike throttling, debouncing is a technique of keeping the trigger rate at exactly 0 until a period of calm and then triggering the listener exactly once.
With Throttling the original function is called at most once per specified period.
With Debouncing the original function is called after the caller stops calling the decorated function after a specified period.
Throttle 1 sec | Debounce 1 sec | |
---|---|---|
Just after triggering | emits the original function | counts down delay for 1 sec |
Subsequent triggers (< 1 sec) | have no effects | restarts delay for 1 sec |
Emits the original function if | the last emit was in more than 1 sec | there were no triggers during the last 1 sec |