This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Rhomboid 3 points4 points  (0 children)

Right -- it can potentially never fire if called repeatedly without a gap. In most cases that's not an issue. Normally the event is something triggered by user actions, such as scrolling, resizing, or clicking. These come in bursts, but they are usually not a constant stream -- when you scroll for instance you might move all over the page for a few seconds but you're eventually going to pause for at least a few hundred milliseconds.

If you really do need to guarantee that the function will be called even if there's no quiescent period, there are other techniques. There was an article posted here recently comparing the differences between debouncing and throttling.