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

Declare Ember.defineProperty as public? #350

Closed
simonihmig opened this issue Aug 1, 2018 · 5 comments
Closed

Declare Ember.defineProperty as public? #350

simonihmig opened this issue Aug 1, 2018 · 5 comments

Comments

@simonihmig
Copy link
Contributor

I am opening this here for discussion, as I have seen confusing statements (to me at least) in other repos/issues, so would like to clarify this here in a central place...

Problem

Ember.defineProperty is declared private, although it seems to be widely used in the wild (see below). IMHO there is at least one valid use case for it, when the dependent keys of a CP are not known it advance.

Status quo

Opinions

  • @ef4 suggested on Slack recently, that it should remain private. The relevant transcript can be found in this issue: Clarify use of private API for deprecation solution ember-learn/deprecation-app#157
  • @rwjblue's comment suggests making it public (if I read it correctly)
  • my own personal take: the use case of declaring CPs with dynamic dependent keys would justify making this public (FWIW, I always considered it public, without checking 🤨). The solution offered by @ef4 (see link above, third bullet point) seems pretty inconvenient for this IMHO valid use case.

/cc @jenweber @ef4 @rwjblue

@rwjblue
Copy link
Member

rwjblue commented Aug 1, 2018

I generally agree with Ed’s points (over in the deprecation app issue), but frankly they do not cover all of the cases where Ember.defineProperty is used. I totally agree that most usages of Ember.defineProperty should be replaced (the polyfill use case, setting CPs on POJOs, etc) with more idiomatic scenarios.

However, Ember.defineProperty is the only way to properly setup a computed property on an ES class (regardless of dynamic dependent keys). “Properly” here means that it sets up the prototypes meta, installs native getters (in 3.1+), sets up “mandatory setter” in development mode, etc. Tooling like ember-decorators therefore must use Ember.defineProperty and it should be marked as public (it definitely meets the bar for intimate API already).

@simonihmig
Copy link
Contributor Author

it should be marked as public

would that require a full-blown RFC process?

@rwjblue
Copy link
Member

rwjblue commented Aug 1, 2018

IMHO, no (it would just require a PR to change the docs from @private to @public), but it is something that we (the core team) should generally agree on before doing.

I'll try to take this to the next core team meeting to confirm we have consensus...

@ef4
Copy link
Contributor

ef4 commented Aug 1, 2018

I defer to @rwjblue on this.

In general it would be nice to flag APIs like this as “advanced” so that newbies don’t encounter them in the normal docs.

@buzzware
Copy link

While the wind seems to be blowing towards static/explicit typing, I hope that Ember continues to provide "sharp knives" like this to enable meta-programming and other dynamic approaches.

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

4 participants