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

Gathering feedback: Support native ES properties for computed properties #12709

Closed
chrisjshull opened this issue Dec 14, 2015 · 2 comments
Closed

Comments

@chrisjshull
Copy link

This issue is intended to gather feedback on making computed properties gettable and settable via native properties (in addition to the get/set methods).

For example, instead of:

myObj.get('computedProperty');
myObj.set('computedProperty', 1234);

You could do:

myObj.computedProperty;
myObj.computedProperty = 1234;

Benefits:

  • No more issues when a native property is swapped out with a computed property, requiring all API consumers to switch to get/set.
    • Alt: no more defensively coding with get/set all the time "just in case". *
  • Better autocomplete/discoverability in REPLs and IDEs.
  • Less typing.
  • More "natural" JS.

* Even if you do this, it can't be applied across the board since you still have to deal with native/non-Ember objects which don't have get/set.

Drawbacks:

  • unknownProperty obviously won't work if you don't actually call get/set. unknownProperty is rarely used - classes tend to declare all of their actual properties. However, if your object actually takes arbitrary properties (like an ES Map), get and set will still be there for you.

Again, not proposing the removal/deprecation of get/set. If you like the methods better, or have use of unknownProperty then they will still be there for you. But I think it would be nice to use native accessors for the majority of cases where you don't even want unknownProperty.

@mixonic
Copy link
Member

mixonic commented Dec 14, 2015

This is likely better as an issue on https://github.com/emberjs/rfcs. Mind re-opening there @chrisjshull?

@chrisjshull
Copy link
Author

Whoops. Roger that: emberjs/rfcs#108

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

No branches or pull requests

2 participants