I have for example the following array:
setup() {
let array = shallowReactive([]);
return {
array
};
}
Using of shallow reactive is important, because this array could contains not reactive objects, that in turn can have reactive fields itself. I need to filter its elements. The following code doesn't work because it creates a new object, that has no common with array that used in the template:
array = array.filter(obj => !obj.empty)
The only known to me way that preserves reactivity is:
array.splice(0, array.length, ...array.filter(obj => !obj.empty))
But it looks ugly and possibly is not effective. Are there any other ways that preserves reactivity?