Skip to content
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

[FEAT] Implements Decorators #17548

Merged
merged 4 commits into from
Feb 8, 2019
Merged

Conversation

pzuraq
Copy link
Contributor

@pzuraq pzuraq commented Feb 2, 2019

This is a continuation of #17226, thanks a ton to @NullVoxPopuli for getting this started!

This PR refactors the Descriptor system in Ember metal, mostly replacing
it with a Decorator system instead. defineProperty has been updated to
apply decorators following the currently implemented spec. This means
that the value returned by computed goes through the exact same flow
when applied as a decorator using decorator syntax, and applied using
classic syntax.

I was considering pulling out the ComputedDecorator stuff into a separate
package, it's relatively isolated from the rest of metal at this point
so it would make some sense. Thoughts?

TODO:

  • Benchmark
  • Disable native application except behind a canary feature flag

@pzuraq pzuraq force-pushed the implement-decorators branch 2 times, most recently from a49dbb5 to 443e536 Compare February 2, 2019 03:28
@pzuraq
Copy link
Contributor Author

pzuraq commented Feb 4, 2019

Thanks @richard-viney!

@pzuraq pzuraq force-pushed the implement-decorators branch 5 times, most recently from 0cebdcb to 4359400 Compare February 5, 2019 03:15
@pzuraq
Copy link
Contributor Author

pzuraq commented Feb 5, 2019

Benchmarked, no statistically significant change in performance when used in classic class syntax! I think this is ready for review 🎉

results.json.txt
results.pdf

@type DOMElement
@public
*/
element: descriptor({
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Followup: We should flatten this class into Component so we don't need to use this decorator

packages/ember/index.js Outdated Show resolved Hide resolved
@pzuraq pzuraq force-pushed the implement-decorators branch 5 times, most recently from 93d42b1 to d3a6a24 Compare February 8, 2019 19:47
NullVoxPopuli and others added 2 commits February 8, 2019 13:05
This PR refactors the Descriptor system in Ember metal, mostly replacing
it with a Decorator system instead. `defineProperty` has been updated to
apply decorators following the currently implemented spec. This means
that the value returned by `computed` goes through the exact same flow
when applied as a decorator using decorator syntax, and applied using
classic syntax.
@rwjblue rwjblue merged commit 528434e into emberjs:master Feb 8, 2019

constructor(config: ComputedPropertyConfig, opts?: ComputedPropertyOptions) {
constructor(args: Array<string | ComputedPropertyConfig>) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this change intentional? Shouldn't it be ...args instead?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed on Discord that it is intentional.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants