I'm using this geographic library with objects like Map and Layer and LayerTree. I'm using Vue to visualize the LayerTree.
Today I noticed however that some layers contain a lot (over 10,000) items that all become reactive, which completely explodes the memory usage. I have no need for this, because I'm only interested in a few attributes of the layer to display the layerTree.
Is it possible to declare certain attributes to be non-reactive?
Since Vue performs the getter/setter conversion process during instance initialization, a property must be present in the data object in order for Vue to convert it and make it reactive. For example: Vue does not allow dynamically adding new root-level reactive properties to an already created instance.
Since Vue doesn’t allow dynamically adding root-level reactive properties, you have to initialize Vue instances by declaring all root-level reactive data properties upfront, even with an empty value:
The only exception to this being the use of Object.freeze (), which prevents existing properties from being changed, which also means the reactivity system can’t track changes. Show activity on this post.
Anything defined outside of what's returned by data method is non-reactive. There's nothing official in a guide about this, but so far it just works.
...,
data() {
// Nonreactive
this.fuu = 'nonreactive'
// Reactive
return {
bar: 'reactive',
}
},
...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With