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
14
votes
3 answers
Typescript debounce function not calling function passed as parameter
I'm trying to write a debounce function with typescript.
I found an example of it in here. Code follows:
export function debounce(
func: (...args: Params) => any,
timeout: number,
): (...args: Params) => void {
let…

Lucas Meine
- 1,524
- 4
- 23
- 32
14
votes
2 answers
VueJS 2 debounce on multiple components
I have a Vue component that uses multiple sub-components on it. And on those sub-components I have a watcher that watches for data changes and processes those changes. I would like to implement debounce for this.
watch: {
data: {
…

Raimundas Juška
- 143
- 1
- 5
14
votes
3 answers
How to kill a Javascript function if it is called again?
I have a search box on my web page that has check boxes in order for the user to filter their results. Only one check box can be checked at once.
When a check box is clicked my code runs off and applies the filter to the list and returns the correct…

Win
- 2,593
- 3
- 25
- 35
14
votes
2 answers
Confused about the maxWait option for LoDash's debounce method
LoDash's debounce accepts an option maxWait.
From the docs:
[options.maxWait] (number): The maximum time func is allowed to be delayed before it’s called.
I'm confused, isn't that just the same as using throttle? What's the difference?

callum
- 34,206
- 35
- 106
- 163
13
votes
1 answer
React use debounce with setState
Background
Assume we all know about the debounce function from lodash.
If a user quickly input 1,12,123,1234, it allows us to proceed an alert only once, with 1234, after a certain delay time.
This is quite used to reduce request amount, for…

keikai
- 14,085
- 9
- 49
- 68
12
votes
4 answers
Lodash debounce async/await
I'm trying to add debounce to my application before I do an api call. However when I introduce debouce, it seems like my await is ignored and the function calls due to missing values
export default class App extends Component {
state = {
…

Batman
- 5,563
- 18
- 79
- 155
11
votes
1 answer
Lodash _.debounce with separate queues for unique argument variants
I really appreciate lodash for its debounce and throttle functionality. I believe I understand the uses cases well and have implemented them dozens of times.
However, depending on requirements, there can be a significant and hard to catch error…

ryanm
- 2,239
- 21
- 31
11
votes
3 answers
Testing a debounced function in AngularJS with Jasmine never calls the function
I have a method in a service that uses underscore's debounce.
Inside that method is a call to a method on a different service. I'm trying to test that the different service is called.
In my attempts to test the debounced method, the different…

Andrew Luhring
- 1,762
- 1
- 16
- 37
10
votes
7 answers
Angular click debounce
In my template I have a field and two buttons:
-
{{ myValue }}
+
In my component .ts file I have:
add(num) {
this.myValue…
Kamil Kiełczewski
- 85,173
- 29
- 368
- 345
10
votes
2 answers
Debouncetime in Angular6 ngModelChange
I have a complex calculator app written in Angular6 which calculates the results based of several inputs in the ngModelChange event and to show these results in charts directly. The calculation is done server side. Now I want to add a debouncetime,…

yannick
- 685
- 1
- 11
- 29
10
votes
1 answer
How to use debounce on async function?
How can I use debounce on an async function? I have a method within my vue-app which reveives data from an API which calls the API continuosly which I want to avoid.
Here is my method:
methods: {
async getAlbums () {
const response = await…

ST80
- 3,565
- 16
- 64
- 124
10
votes
3 answers
using debounce for search input in react
I have a search input, to make API calls on the fly. I'd like to implement debounce to reduce the amount of server calls.
_debouncedSearch() {
debounce(this.props.fetchRoutes(this.state.searchText), 1000);
}
_updateResults(searchText) {
…

leogoesger
- 3,476
- 5
- 33
- 71
10
votes
1 answer
Is it a good idea to use requestAnimationFrame within a debounce function?
This is a check on my understanding of requestAnimationFrame. I have a need for a debounce function, as I'm doing some DOM interaction every time the window is resized and I don't want to overload the browser. A typical debounce function will only…

carpeliam
- 6,691
- 2
- 38
- 42
10
votes
1 answer
How to create a distributed 'debounce' task to drain a Redis List?
I have the following usecase: multiple clients push to a shared Redis List. A separate worker process should drain this list (process and delete). Wait/multi-exec is in place to make sure, this goes smoothly.
For performance reasons I don't want to…

Geert-Jan
- 18,623
- 16
- 75
- 137
10
votes
11 answers
Simple Debounce Routine
Do you have a simple debounce routine handy to deal with a single switch input?
This is a simple bare metal system without any OS.
I would like to avoid a looping construct with a specific count, as the processor speed might fluctuate.

Benoit
- 37,894
- 24
- 81
- 116