-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Closed
Description
So I've been doing some exploring with the composition api, watch, and reactive arrays. Since the array is wrapped in a proxy, if you attempt to use watch on the array, both the old and the new values given to you point to the proxied object and are identical.
I'd like to add a section to the watch guide about how to do proxied object comparisons. For instance, if you are wanting to compare the changes of a proxied array, you would need to provide watch a function that shallow copies the values of the array.
const myArray = reactive([1,2,3,4]);
watch(()=>[...myArray], (newVal, oldVal) =>{
// do things...
})also provide an example for objects.
maybe some wording about utilities that can be used to deeply copy an object/array, such as lodash.cloneDeep
Metadata
Metadata
Assignees
Labels
No labels