Brr: Better ux for inserting reactive elements in the DOM - #64
Open
panglesd wants to merge 8 commits into
Open
Conversation
panglesd
force-pushed
the
better-ux-for-inserting-el-in-dom
branch
from
July 18, 2026 15:15
ada7f98 to
a53c4ae
Compare
voodoos
reviewed
Jul 19, 2026
panglesd
added a commit
to panglesd/slipshow
that referenced
this pull request
Jul 19, 2026
panglesd
commented
Jul 31, 2026
Comment on lines
+450
to
+454
| let root = Lwd.observe children in | ||
| let c = Lwd.quick_sample root in | ||
| El.set_children el (Lwd_seq.to_list c); | ||
| Lwd.quick_release root; | ||
| update_children el children |
Collaborator
Author
There was a problem hiding this comment.
Well there is a bug here. Update_children expects no children at the beginning, so it will add them (again) and we end up with a duplicated initial value.
The fix is probably:
Suggested change
| let root = Lwd.observe children in | |
| let c = Lwd.quick_sample root in | |
| El.set_children el (Lwd_seq.to_list c); | |
| Lwd.quick_release root; | |
| update_children el children | |
| update_children el children |
panglesd
added a commit
to panglesd/slipshow
that referenced
this pull request
Jul 31, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Yo! I finally worked on this.
The way elements are inserted in the DOM in the brr-lwd examples is not ideal. It requires you to understand more of
Lwd's API than necessary, as well asrequest_animation_frame. Moreover it would not work as is for actually reactive elements (only for reactive children, which is the case in the examples).So this PR introduces two ways to insert reactive elements in the DOM directly into the
brr-lwdAPI. The examples are updated to use the two ways. EDIT: based on what I use on slipshow, I addedappend_childandprepend_child.The API mimicks two standard way of inserting nodes in the DOM,
insert_siblingsandset_children, but with reactive siblings/children.The main difference is that
insert_siblingsisinsert_sibling: not plural, it takes a single element instead of at col.It is not really possible to have an
insert_siblings `Replace el seq, as if we replaceelby a reactive sequence that is first empty (so we just removeel) and then non-empty, we lost our anchor to know where to add the new elements.We could still add the following API:
and I suggest to do so but in another PR, as it requires to refactor
update_childrenquite a bit.