Created
October 27, 2019 10:39
-
-
Save enwin/e1db87c8ebd99be73648a330563b97ed to your computer and use it in GitHub Desktop.
Update an array of objects while keeping it reactive for vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default (vueArray, data) => { | |
data.forEach((entry, index) => { | |
if (!vueArray[index]) { | |
vueArray.push(entry); | |
return; | |
} | |
const previousEntry = vueArray[index]; | |
vueArray.splice(index, 1, { | |
...previousEntry, | |
...entry | |
}); | |
}); | |
vueArray.splice(data.length); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment