-
Notifications
You must be signed in to change notification settings - Fork 11.9k
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
Give elements their own interface definition #8290
Merged
Merged
Changes from all commits
Commits
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
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.
When I read
ElementOptions
, I'm thinking of options for an element, and I would expect to be able to extend it for each element type (i.e.interface ArcOptions extends ElementOptions
). Shouldn't this be named differently then, maybeElementsOptions
orElementOptionsMap
or something else that makes it clear it's a record of element type -> element options (ElementOptionsByType
)?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 for the feedback.
I see your point. For what it's worth, the name
ElementOptions
would match the currentPluginOptions
(which seems to serve a similar purpose). Otherwise, I might pickElementOptionsMap
(seems clearest to my personal taste) orElementsOptions
(to be a bit more consistent with pre-existing type definitions' names).I don't have a strong opinion, so I'll defer to others.
After taking another look at this, I realized that I could probably set up a
...Registry
interface; this should serve the same purpose and would be similar to Chart.js's ScaleTypeRegistry and ChartTypeRegistry.Or, using an
options
sub-object to match the other ...TypeRegistries: (This doesn't seem to be necessary for elements, but it's consistent and allows room for future growth.)Thoughts?
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 agree, same problem with
PluginOptions
,ScaleOptions
(and maybe some others). For this last, it's even more confusing because there isCoreScaleOptions
. There is alsoCommonOptions
which is too generic ("common" for what?) and should be renamed since it's not an interface that's supposed to be extend by all options set.I would reserve these
{Type}Options
(i.e.PluginOptions
,ScaleOptions
,ElementOptions
, etc.) for base interfaces, containing common properties for each type (if needed). We could prefix them to make explicit that these are "base" interfaces but I'm not sure I would pickCore
(maybeBase
instead).I'm not convinced by
ElementOptionsMap
finally because it's not a JavaScriptMap
, so could be confusing. I'm not familiar with these*Registry
types, but if it's a common pattern in our TD, then I guess it's a good one. Though, it would need to containOptions
in the name (maybeElementOptionsRegistry
) because we can also have a registry for element (not element options). Then we should also renamePluginOptionsRegistry
,ScaleOptionsRegistry
, etc.I kind like/prefer my last suggestion:
ElementOptionsByType
(PluginOptionsByType
,ScaleOptionsByType
) because it's clear that's a plain object containing a mapping between the type name and options. WithRegistry
, it's a bit confusing because I understand "registry" as an object containing some logic / extra methods (i.e.ScaleOptionsRegistry.register()
).Finally, I would rename
ElementChartOptions
as well (or even better, remove it since I find it useless and making hard to understand the type hierarchy.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'd prefer
ElementTypeOptions
overElementOptionsByType
. Not a strong opinion, just personal preference on naming conventions.