commit
b5b86f4f14
1 changed files with 2 additions and 2 deletions
|
@ -6,7 +6,7 @@ importance: 5
|
||||||
|
|
||||||
The result of `debounce(f, ms)` decorator should be a wrapper that passes the call to `f` at maximum once per `ms` milliseconds.
|
The result of `debounce(f, ms)` decorator should be a wrapper that passes the call to `f` at maximum once per `ms` milliseconds.
|
||||||
|
|
||||||
In other words, when we call a "debounced" function, it guarantees that all other future in the closest `ms` milliseconds will be ignored.
|
In other words, when we call a "debounced" function, it guarantees that all future calls to the function made less than `ms` milliseconds after the previous call will be ignored.
|
||||||
|
|
||||||
For instance:
|
For instance:
|
||||||
|
|
||||||
|
@ -21,4 +21,4 @@ setTimeout( () => f(4), 1100); // runs
|
||||||
setTimeout( () => f(5), 1500); // ignored (less than 1000 ms from the last run)
|
setTimeout( () => f(5), 1500); // ignored (less than 1000 ms from the last run)
|
||||||
```
|
```
|
||||||
|
|
||||||
In practice `debounce` is useful for functions that retrieve/update something when we know that nothing new can be done in such a short period of time, so it's better not to waste resources.
|
In practice `debounce` is useful for functions that retrieve/update something when we know that nothing new can be done in such a short period of time, so it's better not to waste resources.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue