question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

support for `$watch`-ing any property on a vm

See original GitHub issue

I’m trying to subscribe to any data changes made against any property on the vm, not just pre-defined property names. I couldn’t find any way to do it, so here’s my proposal.

I made an example here: http://jsfiddle.net/BBk3j/. In the first $watch, I subscribe to changes on the foo property. The next two $watch statements would be my proposal to allow any watching for updates on any property. Either support a wildcard syntax (which I don’t think is a great idea, because * is a valid property name in JS), or a better syntax that makes the string property name optional.

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:12 (2 by maintainers)

github_iconTop GitHub Comments

25reactions
happilymarrieddadcommented, Mar 24, 2016

this is how you do it with components… Thanks to usmanhalalit

watch:{
    '$data': {
        handler:function() {
            console.log('changed')
        },
        deep:true
    }
},

My next question is how do I tell what changed?? like which variable??

When I console.log out the first argu I get the whole data object… which makes sense but is there a way to tell what specifically changed?

7reactions
NoelDaviescommented, Dec 29, 2015

as mentioned by @guitcastro this still doesn’t mention how to watch an item within a list.

Say I have a list like so

```
data: {
    items: [
        {name: 'a', quantity: 2},
        {name: 'b', quantity: 2},
        {name: 'c', quantity: 2}
    ]
}
```

If I do a watch on this using

```
watch: {
    'items': {
        handler: function (value, mutation) {
        },
        deep: true
    }
}
```

How will I know what item has been mutated / changed?

This is the issue I, nor guys on my livestream can work out.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Get-View Part 1: Introduction to Get-View - VMware Blogs
It may take some practice and some time to get to know what all can be found within the view of each object…...
Read more >
Vue.js - How to properly watch for nested data - Stack Overflow
The $watch returns an unwatch function which will stop watching if it is called. var unwatch = vm.$watch('a', cb) // later, teardown the...
Read more >
Virtual machine instances - Compute Engine - Google Cloud
Compute Engine instances support a declarative method for launching your applications using containers. When creating a VM or an instance template, you can ......
Read more >
Computed Properties and Watchers - Vue.js
That's why for any complex logic, you should use a computed property. ... The function we provided will be used as the getter...
Read more >
Diagnose a virtual machine network traffic filter problem
The steps that follow assume you have an existing VM to view the effective security rules for. If you don't have an existing...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found