Re:Rate-limiting JavaScript function calls
by kwamenum86 on Monday October 15, 2012 @02:13PM
(#4656333)
you probably run into that more with global functions, which this definitely isn't suitable for. but if you trickle a callback that just handles, for example, keydown on a single input, this sort of thing is really useful.
If polling is what's needed then it makes more sense to use setInterval and have a better guarantee of when things are being run. Or you could stuff events into a buffer and have a function consume them periodically - either way, when you lose an event it's either 1. irrelevant, because polling only cares about the state at time t and not the events, or 2. deterministic, because your consumer function decided to get rid of it.