I have a text-field (taken from vuetify library) which is used to filter some table in my application.
<v-text-field
style="min-width: 300px;"
v-model="filterString"
label="Search" />
The working principle is simple - every time when the user provides new filter value, the table content should be updated. There is no submit-button or anything like that. Filtering is implemented on the backend-side, so every update demands sending a request to my API. I use a Vue.js watcher to send a request, when the filter string is updated.
watch: {
async filterString() {
// some logic containing communication with my api
},
},
Let's suppose the user of my application types some 10 letters string in search box. Then, my application sends 10 requests to my API, ignoring the fact that first nine of them are useless. And that's my problem. Should i use the clock, and send a request only if a certain amount of time elapses? Is there some event which is fired when the user finishes typing, that i need to subscribe? How to send a request only when the user finishes typing in my box? Thanks for any answer.