I’m looking at the code for “Debouncing User Input” and the submit function appears to be wrong.
submit(): void {
this.debounce(this.basicSubmit.bind(this))()
}
If I’m reading the code properly, this.debounce
is a function makes debounced version of the function given. (Effectively storing the state on the function itself.) For this to work, there must be a single instance. The code in this.submit
creates a new instance each time it is called, meaning there is no shared state.
Wouldn’t the correct code be:
submit = this.debounce(this.basicSubmit.bind(this))