Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // send req after a few seconds have passed since user last wrote in the editor
- export default function debounce(a,b,c){
- let d,e;
- return function(){
- function h(){
- d=null;
- c||(e=a.apply(f,g));
- }
- let f=this,g=arguments;
- return (clearTimeout(d),d=setTimeout(h,b),c&&!d&&(e=a.apply(f,g)),e)
- }
- }
- // Call it like this (Wait for 1.5s)
- debounce(() => {}, 1500);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement