I have:
async search() {
How can I implement lo dash's denounce? I've tried:
async search: _.debounce(function () {
But with no luck.
Try this:
<input type="text" @keypress="searchDebounce" />
methods: {
async search() {
// get search result
},
searchDebounce: _.debounce(async function() {
await this.search();
// or you can move everything from search() to here, and delete this.search()
}, 1000)
}
or even better:
data() {
return {
searchDebounce: null
};
},
created() {
this.searchDebounce = debounce(this.search, 1000);
}