Debouncing and throttling events utility methods.
Methods
(static) debounce(funcnon-null, timeoutopt) → (non-null) {function}
In the debouncing technique, no matter how many times the user fires the
event, the attached function will be executed only after the specified
time once the user stops firing the event.
Returns a function, that, as long as it continues to be invoked, will not
be triggered. The function will be called after it stops being called for
N milliseconds.
- Source:
- See:
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
func |
function
|
The function to execute. | |
timeout |
number
|
<optional> |
The timeout in milliseconds. |
Returns:
- Type:
-
function
Returns a function, that, as long as it continues
to be invoked, will not be triggered.
(static) throttle(funcnon-null, timeoutopt) → (non-null) {function}
Throttling is a technique in which, no matter how many times the user
fires the event, the attached function will be executed only once in a
given time interval.
Returns a function, that, as long as it continues to be invoked, will only
trigger every N milliseconds.
- Source:
- See:
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
func |
function
|
The function to execute. | |
timeout |
number
|
<optional> |
The timeout in milliseconds. |
Returns:
- Type:
-
function
Returns a function, that, as long as it continues
to be invoked, will only trigger every N milliseconds.