Module debounce.lua
Returns a debounced version of a function.
The returned function delays execution by delay seconds.
If called again before the delay expires, the previous call is cancelled.
Functions
-
# returns... (delay, fn) -
Parameters
- delay number Delay in seconds
- fn function The function to debounce
Returns
-
debounced
The debounced function
-
# debounced (args) -
Wrapper of the fn that adds the debounce behavior.
It forwards all arguments to
fn.Parameters
- args
...
Forwards these args to the fn passed to
debounce.
Returns
-
job
Which allows the user to cancel.
- args
...
Forwards these args to the fn passed to
Table
-
# job -
Fields
- cancel function Stop the debounce from completing.
Usage:
job:cancel()