Created
June 5, 2020 08:39
-
-
Save chairuosen/8cd19ffc8a891854bbaf047cf7893014 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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