Level 11
The Vue documentation recommends using the _.throttle function that comes with lodash https://vuejs.org/v2/guide/migration.html#debounce-Param-Attribute-for-v-model-removed instead of debouncing where you have to wait for the user to finish typing for a certain amount of time before the AJAX request is performed.
Maybe try this pattern:
<input type='text' v-model='yourVariable' @input='sendAjax'>
methods: {
sendAjax: _.throttle(() => {
// send and process
}, 2000)
}
Of course, if you want to, you can also use lodash's _.debounce function in place of _.throttle
1 like