-
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 extensibility to various classes #11859
Conversation
@ggetz I wasn't totally sure how to test these as they modify the global objects and I think that would impact all other specs which is not desirable. Open to ideas |
Thank you for the pull request, @jjspace! Welcome to the Cesium community! In order for us to review your PR, please complete the following steps:
Review Pull Request Guidelines to make sure your PR gets accepted quickly. |
@jjspace I just added you to the Cesium CLA list. You're good to go! |
@ggetz This has been updated with unregister functions and specs for everything except the Entity class (see comment below) |
Object.defineProperties(Entity.prototype, { | ||
[propertyName]: createPropertyTypeDescriptor(propertyName, Type), | ||
}); |
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.
- I'm not entirely sure how to "undo" this change. The only way I can tell it would be possible is to make this property
configurable: true
which then lets medelete Entity.prototype.propertyName
. But I'm not entirely sure we want to make the property fully configurable?- This may point to a deeper issue of needing a better way to create and manage entity type properties.
- I'm also not really sure how to even test and validate the correct properties are set up with the right getter/setter. They'd default to undefined so I couldn't find a nice way to check. Also the
privateName
andsubscriptionName
are not always defined so usingObject.keys
to check doesn't seem like a 100% complete solution.
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.
Discussed offline: Given we'd have to jump through hoops here to make an "unsubscribe" function, we'll omit.
Depending on if we need additional Entity flexibility in the future, we could consider how the types are managed under the hood. But for the scope of this PR, its not needed.
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.
Thanks @jjspace! A few comments, mostly related to documentation.
Object.defineProperties(Entity.prototype, { | ||
[propertyName]: createPropertyTypeDescriptor(propertyName, Type), | ||
}); |
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.
Discussed offline: Given we'd have to jump through hoops here to make an "unsubscribe" function, we'll omit.
Depending on if we need additional Entity flexibility in the future, we could consider how the types are managed under the hood. But for the scope of this PR, its not needed.
* Add the specified type and construct the properties for it in the Entity class | ||
* @private | ||
* @param {string} propertyName | ||
* @param {any} Type |
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.
Strictly speaking this would be
* @param {any} Type | |
* @param {object.constructor} Type |
right?
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.
I know this is marked as private, but typically we do add descriptions for each parameter. That applies here and throughout this PR.
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.
More and more often I go down rabbit holes dug by JSDoc being old and not maintained.
object.constructor
is not a type. After a quick google search I came across this issue jsdoc/jsdoc#1349 which, paired with other JSDoc knowledge, seems to indicate there's no way to really specify "any class" as a type. The best I think we can do is specify a type of {{ constructor: function }}
to try and only accept objects with a constructor function?
@ggetz thanks for the comments, I believe I've addressed them all |
Thanks @jjspace! I updated Once CI passes, this should be good to go. |
Thanks @ggetz I just forgot to link them. Looks like this is good now! 🙏 |
Description
Add new functions to register various updaters and visualizers to support custom entities and data constructs.
Issue number and link
No issue
Testing plan
Author checklist
CONTRIBUTORS.md
CHANGES.md
with a short summary of my change