Feature Request: determine if a reactive object is observed by any Vue instance
See original GitHub issueI would like to request a new feature. I want to determine if a reactive object is observed by any Vue instances.
Example:
var obj1 = {name: 'obj1'};
var obj2 = {name: 'obj2'};
var app = new Vue({
el: '#app',
data: {
item: {}
},
mounted: function onMounted(){
this.item = obj1;
this.item = obj2;
},
methods: {
pickItem: function pickItem() {
this.item = items[this.pickedElemId];
}
}
});
I want to determine if obj1 is observed by any Vue instances. In this example it is clear that the obj2 is observed but obj1 is not.
The reasons behind this feature request is discussed in this issue: https://github.com/vuejs/vue/issues/4384
Issue Analytics
- State:
- Created 7 years ago
- Comments:9 (4 by maintainers)
Top Results From Across the Web
Reactivity Fundamentals - Vue.js
It only works for object types (objects, arrays, and collection types such as Map and Set ). It cannot hold primitive types such...
Read more >Your guide to reactivity in Vue.js - LogRocket Blog
Get a better understanding of reactivity in Vue.js and see how to achieve reactivity in Vue 3 using proxies.
Read more >Reactivity In Vue - Smashing Magazine
Here, we imported the reactive method from Vue, and then we declared our user variable by passing its value to this function as...
Read more >Thought on Vue 3 Composition API - `reactive()` considered ...
reactive (obj) will return a new object that looks exactly the same as obj , but any mutation to the new object will...
Read more >Understanding the New Reactivity System in Vue 3 - SitePoint
For each component instance, Vue creates a dependencies watcher instance. Any properties collected/tracked as dependencies during the ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
You can already check it now using the (private)
__ob__
property.Though I don’t know if it’s worth adding a public API for it. Maybe
__ob__
is good enough (at least for 2.x)?The pattern discussed in this (https://github.com/vuejs/vue/issues/4384) issue is a suitable workaround for the problem so this feature request is unnecessary.