Open st-schneider opened 6 years ago
Not sure I understand the question. Would you like Melody to pick up on data that you've rendered on the server side using Twig/PHP automatically?
That unfortunately won't work. You'd need to serialize the data and pass it to the client side in another way, for example by doing <script>INITIAL_STATE = {{ _context | json_encode() }}</script>
(making sure this is only done in a template rendered on the server side).
When rendering the template on the client side using the same data as on the server side, Melody will however be smart enough to keep the existing DOM nodes in place.
Is there any way to inject the context into a store automatically maybe? Where can I inject the context for my component? Only when the render function is called or when I assemble the component? There seem to be some white spots in the documentation for this :)
Wouldn't the storaging of the whole context go against the information hiding principle? Just thinking about DSGVO
We usually use redux to maintain a global state with components connecting to it (via melody-redux
). Not sure how the DSGVO fits here since you'd just be transporting state from backend to frontend but wouldn't move it out of the users control.
Is it possible that, if I have product information for example, that gets fed into the twig template and expected as a 'product' variable in twig, to be available in melody as well?