I stumbled upon the code snippet below:
let customHandler;
clearTimeout(customHandler);
customHandler = setTimeout(() => {...});
This code example is actually part of a Vue application and consists of the following method:
public handleMultiSelectInput(value): void {
if (value === "") {
return;
}
clearTimeout(this.inputTimeoutHandler);
this.inputTimeoutHandler = setTimeout(() => {
axios.get(`${this.endpoint}?filter[${this.filterName}]=${value}`)
.then(response => {
console.log(response);
})
}, 400);
}
It seems like this is some sort of debounce function, but can someone provide more clarity on its purpose?