-
Notifications
You must be signed in to change notification settings - Fork 837
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
[Tree] Make TreeNode an immutable Sequence to allow for walking the tree #1398
Comments
👍 I just needed this for writing code that "focuses" the tree on a specific node, collapsing all nodes other than one specific node. In my use-case I get only the names of the nodes (labels), not the nodes themselves, along them path; so have to traverse children. |
Making the list public invites a few problems. A dev might expect to be able to extend, remove etc and the tree to update accordingly. I think we should provide for the use-case of iterating children, and walking a sub-tree without exposing the list. |
I'm thinking perhaps we should make TreeNode a Sequence, to allow for iterating. This would allow for walking a tree while not exposing internals. |
children
a public property of a TreeNode
In anticipation of satisfying Textualize#1398, this adds a generic immutable sequence wrapper class. The idea being that it can be used to wrap up a list or similar, that you don't want the caller to modify. This commit aims to get the basics down for this, and also adds a minimal set of unit tests.
Don't forget to star the repository! Follow @textualizeio for Textual updates. |
In anticipation of satisfying #1398, this adds a generic immutable sequence wrapper class. The idea being that it can be used to wrap up a list or similar, that you don't want the caller to modify. This commit aims to get the basics down for this, and also adds a minimal set of unit tests.
Especially to allow some initial "just so" setup of a
Tree
, but also to make it easy to write code to walk aTree
, it would be useful to have public access to thechildren
of aTreeNode
.The text was updated successfully, but these errors were encountered: