Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
A Vue debounce example leveraging Lodash
<template>
<div>
<div class="col-md-6 vertical-center" v-for="(user, index) in users" :key="index">
<input type="text" @input="updateUsername(user)" class="form-control" v-model="user.name">
</div>
</div>
</template>
<script>
export default {
data() {
return {
users:[ {
'name':'user@user.com',
'id':1,
},
{
'name':'user2@user.com',
'id':2,
}
]
}
},
methods: {
updateUsername: _.debounce((user) => {
axios.patch(`/api/user/${user.id}`, user).then((res) => {
swal('Updated');
})
}, 2000),
}
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.