How can i add debounce time to dynamic search box that searches data on table data ? I have looked at some solution on the site but my code is little bit different, I do not use any throttle or something else so I am just confused.
my template code:
<input matInput (keyup)="applyFilter($event.target.value)" placeholder="Search element">
and typescript for that is:
applyFilter(filterValue: string) {
this.tableDataSource.filter = filterValue.trim().toLowerCase();
}
I want to add debounce time for that the search will be made every 2 seconds and not sending lots of request for every change.
Thanks in advance
I have tried to call the method from another method with pipe
filterData(filterValue: string) {
this.applyFilter(filterValue).pipe(debounceTime(2000))
}
but now it says, pipe does not exist on type void