Join the Stack Overflow Community
Stack Overflow is a community of 6.6 million programmers, just like you, helping each other.
Join them; it only takes a minute:
Sign up

I want to create a Vue.js component that receives properties from its parent component, e.g.:

<table-cell :value="foo" format="date" />

Because value and format are defined as properties, Vue will automatically register observers to their values. That is fine in general, but for my use case I positively know those values are not going to change so they don't need to be observed.

Given that my table cell component can be in a table with, say, 1,000 rows and 10 columns, those 2 properties will create 20,000 observers, and I want to avoid all this overhead (and my real table cell component has more complex properties).

Is there any way to disable a component property from being observed in order to avoid wasting CPU & memory resources?

share|improve this question

Pass it with custom data I think like <your-component data-value='foo' data-format='date'>

It will do what you want.

share|improve this answer
    
Unfortunately that won't work: you are just adding a reference to a dynamic property, which will still be observed, even if you delete this.dinamicProp. – Luis Crespo 11 mins ago
    
use slot and pass static data in slot ? – M U 10 mins ago
    
The slot option could work for a single & text-only property. If I need to pass several properties and some of them may be objects, I would have to parse complex text, and that would defeat the original purpose. – Luis Crespo 4 mins ago
    
pass as custom data. – M U 3 mins ago

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.