I am using debounce NPM package and implemented like this:
1 2 3 4 5 6 7 | <input @input="debounceInput"> methods: { debounceInput: debounce(function (e) { this.$store.dispatch('updateInput', e.target.value) }, config.debouncers.default) } |
Using lodash and the example in the question, the implementation looks like this:
1 2 3 4 5 6 7 | <input v-on:input="debounceInput"> methods: { debounceInput: _.debounce(function (e) { this.filterKey = e.target.value; }, 500) } |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.