Polyfill

function debounce(func, wait) {  
let timeout;  
  
return function() {  
	const context = this;  
	const args = arguments;  
	  
	clearTimeout(timeout);  
		timeout = setTimeout(() => {  
			func.apply(context, args);  
		}, wait);  
		};  
}
  • Tried applying this for a click event that was happening twice, wasn’t able to get it working. Here is the code.
showWaveHeightGrid(e) {
    this.debounce()();
  }
 
  debounce() {
    let timeout;
    return () => {
      clearTimeout(timeout);
      timeout = setTimeout(() => {
        this.addWaveValueLayer();
        this.isWaveHeightVisible = !this.isWaveHeightVisible;
      }, 1000);
    };
  }