0

I am creating a Todo app using electron and vue.js

I have an array of objects named items. Each object have the following syntax:

{id: <Number>, item: <String>, complete: <Boolean>, starred: <Boolean>}

I want to save the items array in a file whenever any content (including object attributes) change inside the array for which I need to watch for the changes.

I have tried Vue's watch, but it only triggers when an object is added or removed and not when an object's attributes change.

Here's a screenshot of the program with devTools open. I added an item, starred it and completed it. So, I expect 3 console logs but I get only one (when the object is added).

Todo App Screenshot

Any ideas??

2 Answers 2

1

Use deep to watch object changes:

watch{
  item: {
     handler(newValue, oldValue){
       // something
     },
     deep: true
  }
}
Sign up to request clarification or add additional context in comments.

Comments

1

If you use Vue.set() then the props of each item-object are reactive too.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.