supermedium / superframe

:package: A super collection of A-Frame components.
https://supermedium.com/superframe/
MIT License
1.37k stars 423 forks source link

[template] Recompile template if data changes #103

Open mattrei opened 6 years ago

mattrei commented 6 years ago

Hi,

currently I am trying to use the template component with the state component to dynamically update the rendered template when a data- attribute changes. The data changes however the template does not get rerendered.

Is this a good use case for using templates or should I switch to React? Because I am having quite some UI state that needs to be drawn dynamically. I wanted to overcome React with the beautiful state and template component... However it seem to be though to handle this issue.

Best

ngokevin commented 6 years ago

Can you make more fine-grained operations based on the state? e.g., rather than re-rendering an entire group of entities, do only the things you need. Such as changing component properties. If there is a case where you do need to change an entire group of entities, you can make a component on a parent entity that manages the children, and does stuff when state changes.

ngokevin commented 6 years ago

One thing I have is a render-entities component, and I bind dirtyIds from state to that component. And when dirtyIds change, render-entities will create/remove/update entities. My application though only has one instance where I need to do these types of things, so it works for me.

mattrei commented 6 years ago

I understand. So each child of the node gets its unique DOM id and you manage those within an array. I like that approach and I will follow it.

Anyway, would you propose the change in the template component, that means rerender the template when the data changes? Or might it inflict too much on the performance?