Skip to content

Instantly share code, notes, and snippets.

@chairuosen
Created June 5, 2020 08:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chairuosen/8cd19ffc8a891854bbaf047cf7893014 to your computer and use it in GitHub Desktop.
Save chairuosen/8cd19ffc8a891854bbaf047cf7893014 to your computer and use it in GitHub Desktop.
function debounce(){
let lock = false;
return function(fn){
return async function(...args){
if(lock) return;
lock = true;
try{
let res = await fn(...args);
lock = false;
return res;
}catch(e){
lock = false;
throw e;
}
}
}
}
let d = debounce();
this.aaaFn = d(this.aaaFn.bind(this))
this.bbbFn = d(this.bbbFn.bind(this))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment