Prevent double click on button angular 8 code example
Example: angular prevent double click
// <button (click)="clickEvent.next()">Click Me</button>
class YourComponent implements OnInit {
clickEvent = new Subject();
ngOnInit() {
// throttleTime() executes the event immediately, and discards
// any new events until 300ms have passed.
this.clickEvent.pipe(throttleTime(300))
.subscribe(() => console.log('Clicked'));
// debounceTime() delays the event by 300ms, and the timer resets
// if another event occurs.
this.clickEvent.pipe(debounceTime(300))
.subscribe(() => console.log('Clicked');
// remember to unsubscribe() !!!
}
}