stopping a function if called within 5 sec again in typescript or javascrit
stopping a function if called within 5 sec again in typescript or javascrit
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
stopContent = false; getFeed(){ if(this.stopContent == false){ /* stop more on next click */ this.stopContent = true; /* allow more feeds after 5 sec */ setTimeout(e=>{ this.stopContent = false;}, 5000); console.log('feeding'); /* your code here */ }else{ console.log('stopping'); } } |