Dynamic Dom
#1080
Replies: 1 comment
-
This is working pretty well with |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
In 0.3, or maybe 0.2 we added support for dynamic dom. Consider this code:
We are using
show-person
component for every member of the list.What happens if we dynamically modify the list as part of some event handler? The user expectation, and our declarative nature requires we dynamically construct another instance of
show-person
and place it in the right place in the DOM.We kind of do that right now, we do it by calling
show-person
(and every component used in such loops rooted on mutable lists, with dummy values, and store the generated DOM as template DOM in the page somewhere, so when the time comes to construct the new dom for the newly added list item, we clone the template dom, and update all variables.Bug: we do not attach the event handlers. This is because we maintain a variable dependency graph, and we will have to update the graph has well, as now we are create more variables.
We could have done it, we can store more data to help us construct the tree, but the way we construct dom on backend and frontend was diverging wildly, and we will end up with two ways of doing things, leading to subtle bugs and differences. We left this as open item. No event handlers on dynamic dom will work, was left as a known issue till now.
In 0.4 release we are re-architecting the way our server side interpreter works. In 0.3 we have a kind of interpreter that interprets the ftd document. In 0.4 we are compiling ftd document to javascript, and running the javascript on both server (using quickjs) and on frontend.
This approach guarantees that same logical code executes on both server and client, and we regenerate all dependency graphs and DOM.
Since in the 0.3 we did not have any way to reliably dynamic construct DOM, we used to construct entire DOM, both for say dark and light mode, and both for desktop and mobile version etc, so the HTML size used to be also more than what is needed.
Beta Was this translation helpful? Give feedback.
All reactions