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.
Usage
Returns
ui.util.rateLimit(func, delay, scope)
Function
Argument
Type
Details
func
Function
Function to call.
delay
Number
After the function is called and executed, the number of milliseconds to delay before allowing an additional invocation of the function.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2023-10-06 UTC."],[[["Limits a function's execution to at most once per specified interval, preventing rapid, repeated calls."],["Useful for optimizing expensive functions or preventing unintended double-click actions, such as on UI buttons."],["Returns a rate-limited version of the original function, accepting the function, delay, and optional scope as parameters."],["Utilizes a delay mechanism to ensure subsequent calls are ignored until the interval has elapsed, guaranteeing controlled execution."]]],[]]