-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Add children getter to entity #10324
Closed
Closed
Changes from 4 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
7df4595
feat: add children getter to entity
jdfwarrior 8066c7f
feat: add children getter to entity
jdfwarrior 641abb0
add name to contributors
jdfwarrior da12acd
add unit tests for new code
jdfwarrior 79276cf
add comment to the changelog
jdfwarrior dbec768
Merge branch 'CesiumGS:main' into main
jdfwarrior e1522f5
Merge remote-tracking branch 'origin' into add-children-getter
635398e
Merge branch 'CesiumGS:main' into main
jdfwarrior b284e54
Merge branch 'main' into add-children-getter
jdfwarrior e4f50bb
chore: remove previous edits that added children getter
jdfwarrior da6b1d1
chore: added basic tests for new code added
jdfwarrior 6e98272
feat: added children getter to return the children count and getChild…
jdfwarrior d8789d4
chore: update changelog
jdfwarrior File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will mark the property explicitly as read only in the docs and the generated typescript definitions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also I believe what @mramato was alluding to is that while, yes, this is only a getter and not a setter, its possible to get the array of children and then mutate it by adding or removing elements. Either of which could have adverse effects.
We work around this in other classes such as
ClippingPlaneCollection
by not providing direct access to the internal array, and instead providing interfaces for getting the array length (length
) and accessing each element by index (get(i)
).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ggetz So is there any point in adding the @readonly argument to the jsdoc block or should there just be a different implementation of this?
We could also spread or copy the original array to prevent it from being mutated as well. If that is considered a viable alternative, I can make that change. If so, seeing as how there are multiple methods of cloning an array, is there a preferred method?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not if this specific getter goes away, I just wanted to quickly point it out in case it comes up again.
I see what you're saying, but I'd hesitate to recommend this way. I don't see anything similar in the rest of the codebase, most likely for performance reasons. It could get expensive if the getter is called frequently and if there are enough entities.