minor fixes

This commit is contained in:
Ilya Kantor 2020-05-06 22:46:26 +03:00
parent 458493781f
commit 0444de2a00

View file

@ -4,11 +4,9 @@ importance: 5
# Debounce decorator # Debounce decorator
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.11/lodash.js"></script> The result of `debounce(f, ms)` decorator is a wrapper that suspends calls to `f` until there's `ms` milliseconds of inactivity (no calls, "cooldown period"), then invokes `f` once with the latest arguments.
The result of `debounce(f, ms)` decorator should be a wrapper that suspends any calls to `f` and invokes `f` once after `ms` of inactivity. For instance, we had a function `f` and replaced it with `f = debounce(f, 1000)`.
Let's say we had a function `f` and replaced it with `f = debounce(f, 1000)`.
Then if the wrapped function is called at 0ms, 200ms and 500ms, and then there are no calls, then the actual `f` will be only called once, at 1500ms. That is: after the cooldown period of 1000ms from the last call. Then if the wrapped function is called at 0ms, 200ms and 500ms, and then there are no calls, then the actual `f` will be only called once, at 1500ms. That is: after the cooldown period of 1000ms from the last call.