Currently, I am developing a program that utilizes a method to display data in a table using a textbox. The issue is that the program is being called more than 10 times with each execution. Is there any way to prevent this from happening?
The textbox element is displayed below:
<input #input matInput placeholder="Search data" (keyup)="onKeypressEvent($event)">
Below is the method being invoked:
onKeypressEvent(event: any){
fromEvent(this.input.nativeElement,'keyup')
.pipe(
debounceTime(150),
distinctUntilChanged(),
tap(() => {
this.paginator.pageIndex = 0;
this.loadData();
})
)
.subscribe();
}