Debouncing ensures that a handler is not executed too often for an event that may be happening several times per second.
Questions tagged [debouncing]
698 questions
7
votes
1 answer
How can I debounce using async/await?
I have an input box. After the user has stopped typing, I want to perform an HTTP request and await the results.
Here's a jsbin
Since network requests aren't allowed on jsbin, I've used setTimeout() instead.
var log = console.log.bind(console)
var…

mikemaccana
- 110,530
- 99
- 389
- 494
7
votes
1 answer
Debounce function calls by their arguments
David Walsh has a great debounce implementation here.
// 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. If `immediate` is…

Dorad
- 3,413
- 2
- 44
- 71
7
votes
1 answer
How to create a Rails/Ruby method similar to javascript throttle/debounce function
In our application we expose a callback route for an external service to hit. When we receive the callback, we publish an update to client-side subscribers using Eventsource on the client/browser-side and cramp on the server side. Sometimes,…

daino3
- 4,386
- 37
- 48
6
votes
1 answer
explain useCallback when using debounce
When calling just the debounce function like this:
const handler = debounce(someFunction, 2000);
It will call the someFunction on every keystroke. But when we wrap it in useCallback, it works fine.
const handler = useCallback(debounce(someFunction,…

gacat
- 116
- 1
- 13
6
votes
2 answers
Debounce onChange
I have a Material UI Textfield that contains an onChange.
This onChange, takes the event and execute the function handleOnChange. With this current implementation, the function handleOnChange is executed every-time the event changes.
It it possible…

Magofoco
- 5,098
- 6
- 35
- 77
6
votes
1 answer
How does the Throttle publisher work in Swift Combine?
I'm stuck with Throttle publisher. I don't understand the way it picks intervals. Debounce publisher is much easier to understand, it picks an interval after each published value and checks whether new values are posted during the interval or not.…

iWheelBuy
- 5,470
- 2
- 37
- 71
6
votes
1 answer
What is the difference between assigning a variable value with functionName() and just functionName?
const heightOutput = document.querySelector('#height');
const widthOutput = document.querySelector('#width');
function reportWindowSize() {
heightOutput.textContent = window.innerHeight;
widthOutput.textContent =…

Shachar
- 53
- 6
6
votes
2 answers
How to pass in arguments in debounce
const debounce = (func) => {
return (arg) => {
let timeoutId;
if (timeoutId){
clearTimeout(timeoutId);
}
timeoutId = setTimeout(() => {
func(arg);
}, 1000);
}
}
function…

Brian Bui
- 103
- 1
- 6
6
votes
1 answer
fakeAsync does not work with debounceTime
I'm trying to write unit test for function in Angular app with debounceTime (rxjs). And use fakeAsync for asynchronous testing.
And it looks that in test debounceTime gets resolved immediately even if I don't set tick() or set it with small…

Alex Vovchuk
- 2,828
- 4
- 19
- 40
6
votes
1 answer
How do you mock lodash debounce.cancel with jest?
Looking for some recommendations on how to mock the .cancel method in a debounce from lodash.
I have a function that is calling debounce and then later utilizing the returned debounce value to call debouncedThing.cancel().
I am able to mock debounce…

Steph M
- 2,152
- 1
- 12
- 11
6
votes
2 answers
Why rxjs debounceTime does not work on observables created using 'of' operator?
Using angular 7 and rxjs 6:
Why the following does not debounce?
onChange(val: string) {
of(val)
.pipe(
debounceTime(300)
).subscribe(valx => {
console.log(valx);
…

kmansoor
- 4,265
- 9
- 52
- 95
6
votes
0 answers
How should I combine debounce with a MutationObserver
I would like to know when the mutations have stopped being called. I am therefore implementing a debounce. However my console.log('*****Debounced ****'); is never called.
Could you please help me to understand what I am doing wrong.
var target =…

darbid
- 2,545
- 23
- 55
6
votes
1 answer
How do I create a leading debounce with redux-saga
Is there a way to do a leading debounce?
The example on the recipes only shows a trailing debounce. So below is trailing debounce example where we delay the logic fro 500ms:
import { call, cancel, fork, take, delay } from…

christoffee
- 633
- 1
- 6
- 15
6
votes
1 answer
Listen to the value change of multi ranges with debounce
Currently, I use the following code to listen to the change of Sheet1!A1:B2:
function addEventHandler() {
Office.context.document.bindings.addFromNamedItemAsync("Sheet1!A1:B2", "matrix", { id: "myBind" }, function (asyncResult) {
…

SoftTimur
- 5,630
- 38
- 140
- 292
6
votes
3 answers
Cancelling method calls when the same method is called multiple time
I think there's probably a name for what I'm describing here, but I don't know it. So my first question would be to know the name of this technique.
Here's an example: suppose you're implementing live search on a web page. Everytime the user types…

ARRG
- 2,476
- 17
- 28