On page load I receive an array of objects from the server, which are displayed using a v-for
loop.
The application is real time, so when another user updates an object in the array, I receive a pusher event which contains the updated object (this is a Laravel 5.4 broadcast event containing the updated model).
How do I then locate that object within the array to replace it with the updated version?
Example component JS
export default{
data(){
return {
items: []
}
},
mounted(){
...some code to get the array from the server
this.items = server.response;
},
created() {
Echo.private('channel-name)
.listen('event', (event) => {
**What do I do here with the received model to update the items array?**
});
});
}
}
via Joe