Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding, deleting or updating rows of a list #35

Open
edko99 opened this issue Jan 10, 2023 · 2 comments
Open

Adding, deleting or updating rows of a list #35

edko99 opened this issue Jan 10, 2023 · 2 comments
Labels
question Further information is requested

Comments

@edko99
Copy link

edko99 commented Jan 10, 2023

Is it possible to add functionality to send a signal to a list view that the underlying data has changed, like for example that some rows were added, deleted, or changed? In addition to the straightforward use, this would allow trees to be implemented on top of lists: deleting rows can be used when collapsing, and inserting rows when expanding.

@xStrom xStrom added the question Further information is requested label Feb 8, 2023
@xarvic
Copy link
Collaborator

xarvic commented Mar 7, 2023

Sorry for the slow response.
I hope i understand the question correctly. The think you want to achieve is already possible. You can create a Tree view which uses a List widget and only rebuilds the views, which are currently expanded. If you add a node to the tree datastructure, your tree view is rebuild automatically.
But the way lists work is currently in flux. We will probably merge the List view and the LinearLayout view, and allow variable length ViewSequences instead. Here you can find a discussion about it.
One last note. Doing what you proposed is fine for a simple Tree view, but we probably want a dedicated Tree view and widget, since otherwise we would have to put functionality specific to trees into the LinearLayout widget and make it possible for ViewSequences to interact with it.

@raphlinus
Copy link
Contributor

There's a lot more to say about this, and I will address it in a future blog post (this is actually next in my queue and I have a draft, but am seriously overloaded).

In the "small" case, indeed you can represent the list as a Vec (or some other similar sequence type), and then have a corresponding view that diffs it against the previous value. This involves making the ViewSequence trait a little more powerful, specifically able to handle variable numbers of items in the sequence, and also containers better at tracking their children so they can handle insert, remove, and reorder.

However, that approach will lead to performance problems as the number of items scales. For the "big" case you need virtualization so you're not touching all the list items every update. One approach is Dongdong's [virtual list] in floem. However, the direction I'm going is to use a sequence with sparse diffing, as in my RustLab 2020 talk. I believe this will combine excellent ergonomics with excellent performance, but is pretty far from being implemented at this point.

Sorry I can't give a more precise roadmap at this point.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants