Note that throttle does not schedule invocations, but rather acts as a filter that
sometimes allows follow-through to callback, sometimes not. There is an expectation then
that the return function from throttle is repeatedly called, such as the case for handling
a stream of data/events.
Example: Manual trigger
// Set up once constt = throttle( (elapsedMs, args) => { ... }, 5000);
// Later, trigger throttle. Sometimes the callback will run, // with data passed in to args[0] t(data);
Throttles a function. Callback only allowed to run after minimum of
intervalMinMs
.Example: Only handle move event every 500ms
Note that
throttle
does not schedule invocations, but rather acts as a filter that sometimes allows follow-through tocallback
, sometimes not. There is an expectation then that the return function fromthrottle
is repeatedly called, such as the case for handling a stream of data/events.Example: Manual trigger