-
-
Notifications
You must be signed in to change notification settings - Fork 4k
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
refactor: make public builder props getters #7422
Merged
iCrawl
merged 18 commits into
discordjs:main
from
suneettipirneni:refactor/builder-getters
Feb 13, 2022
Merged
refactor: make public builder props getters #7422
iCrawl
merged 18 commits into
discordjs:main
from
suneettipirneni:refactor/builder-getters
Feb 13, 2022
Conversation
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
github-actions
bot
requested review from
iCrawl,
kyranet,
SpaceEEC and
vladfrangu
February 7, 2022 14:52
almeidx
requested changes
Feb 7, 2022
kyranet
requested changes
Feb 7, 2022
packages/builders/src/components/selectMenu/UnsafeSelectMenu.ts
Outdated
Show resolved
Hide resolved
suneettipirneni
force-pushed
the
refactor/builder-getters
branch
from
February 7, 2022 20:10
891e99b
to
94707bb
Compare
Jiralite
reviewed
Feb 8, 2022
packages/builders/src/components/selectMenu/UnsafeSelectMenu.ts
Outdated
Show resolved
Hide resolved
packages/builders/src/components/selectMenu/UnsafeSelectMenuOption.ts
Outdated
Show resolved
Hide resolved
SpaceEEC
approved these changes
Feb 9, 2022
suneettipirneni
force-pushed
the
refactor/builder-getters
branch
from
February 9, 2022 16:54
bf36eec
to
2eec581
Compare
6 tasks
kyranet
requested changes
Feb 9, 2022
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.
Just one last thing, then LGTM.
kyranet
approved these changes
Feb 9, 2022
iCrawl
approved these changes
Feb 9, 2022
vladfrangu
requested changes
Feb 10, 2022
packages/builders/src/components/selectMenu/UnsafeSelectMenu.ts
Outdated
Show resolved
Hide resolved
This needs a rebase |
vladfrangu
previously requested changes
Feb 12, 2022
Co-authored-by: Jiralite <[email protected]>
Co-authored-by: Jiralite <[email protected]>
Co-authored-by: Antonio Román <[email protected]>
suneettipirneni
force-pushed
the
refactor/builder-getters
branch
from
February 13, 2022 03:33
584f980
to
4be95ae
Compare
vladfrangu
approved these changes
Feb 13, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This is a replacement for the previous pr since gh is having trouble loading the diffs.
Please describe the changes this PR makes and why it should be merged:
Stores raw api data in a
data
object and allows access to builder properties via getters.Rationale
There's quite a few benefits in using getters for builders:
Currently builders relies on
Reflect#set
which is much slower than direct prop assignment, in one benchmark I did it was waaay slower than direct assignment. Beyond performanceReflect#set
is less typesafe since property keys are strings and it allows values to be set asany
. This PR removes the usage of these methods, and preserves thereadonly
nature of the fields.The classes are now more flexible. For example, right now if we decided to add a field to any builder class, it would be outputted in
toJSON
simply becausetoJSON
just spreadsthis
:{ ...this }
. In addition, since we now have getters we can do any computation before a value is returned unlike a regular field.Constructor assignment is easy, in some cases it's just assigning
this.data = data
.toJSON
is straightforward as well, as it's essentially just returning a copy ofthis.data
.Allows for idiomatic js/ts class field naming. The props are simply retrieved from
this.data
so they're not constrained to any naming conventions used by the API.Status and versioning classification: