I got a vue object like this:

var vm = new Vue({
            el: '#app',
            data: {
                items: [],
                index: 0
            },

            });

Inside items array i will push items like:

item1 = {
    a: 1,
    b: 'type',
    c: '3.556'
}
...
itemN = {
    a: n,
    b: 'type',
    c: '5.226'
}

then i will update one of the item's "c" property and i would like to set up a watcher that warn me as soon as one of this property changes.

EDIT: i also want to know witch item has changed

share|improve this question

There deep watching available in VueJS.It works like this

watch: {
  propertyToWatch: {
    handler() {
      alert('Change detected')
    },
    deep: true
  }
}

https://vuejs.org/v2/api/#watch

share|improve this answer
    
The problem is that every time it triggers, I would like to know witch item has changed – Plastic Jan 8 at 11:05
    
The handler takes two properties representing the old and new values handler(oldVal, newVal). You can use this to see which values changed. – Soviut Jan 8 at 11:15
    
it passes me the whole array, i wold like to get the changed item – Plastic Jan 8 at 11:25
    
Well if you are watching the whole array, of course it would return it whole array at the end. – Belmin Bedak Jan 8 at 11:31
    
my goal is, if "b" and/or "c" properties were changed, to get the item that own those properties – Plastic Jan 8 at 11:41

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.