Stay organized with collections Save and categorize content based on your preferences.

Wraps a function to allow it to be called, at most, once per interval. If the wrapper function is called more than once, only the first call will go through, and no subsequent invocations will have an effect until the interval has elapsed. This can be used to ensure a function that is expensive to run executes immediately but doesn't execute repeatedly.

Example use: For the callback to a click on a ui.Button, in order to prevent the button from being accidentally double-clicked and the callback running twice.

Returns the rate-limited function.

ui.util.rateLimit(func, delay, scope)Function
funcFunctionFunction to call.
delayNumberAfter the function is called and executed, the number of milliseconds to delay before allowing an additional invocation of the function.
scopeObject, optionalObject in whose scope to call the function.