-
-
Notifications
You must be signed in to change notification settings - Fork 408
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
Deprecate computed().meta()
#441
Conversation
We do make use of Our use case is from a macro function that returns a CP. We add some metadata to the CP which we use in tests in order to verify that the property was passed the expected configuration. I guess we could fairly easily switch to a different way of doing this - and we probably will need to as we convert to ES6 classes / decorators anyway. I just wanted to call out that the functionality is being used in more places than a search of open source code would have returned... |
Hey @vitch! That's great to hear from you as a user of the API, I absolutely understand that it's not possible search all Ember code and that there may be users in private code that I don't have visibility into. The searches through emberobserver.com are generally used as barometer, because usually usage is fairly similar in private and public spaces - for instance, For the RFC itself, I'll clarify that there will be a deprecation guide for any existing users. In the documentation section, I was mainly trying to stay away from documenting the usage of private APIs like |
I need some clarification on this. Is this trying to remove the ability to attach meta properties to computed property or just trying to change the way it is exposed? |
We are trying to remove the ability to do it directly. Instead, the recommended path forward would be to use a const META = new WeakMap();
function myComputedMacro() {
let cp = computed(...);
META.set(cp, { /* meta information here */ };
}
// later on
let cp = myComputedMacro();
META.get(cp); // this is how you access your meta information. This way, storing meta information would be entirely user code, without any framework code. This is the same pattern that will likely be used in the future with native decorators, in JavaScript apps in general, not just Ember. We are also talking about changing private APIs, such as |
👍 all for this. We do make use of this in EmberData but it's something we can refactor away trivially and I've been meaning to do so. |
While not directly related to removing meta (we could do so without removing use of computed), I did find that removing the use of computed from EmberData required multiple intimate APIs and ultimately hit a blocker in which |
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 think there's a path forward here for EmberData without computed.meta. I would note though that one thing that this RFC does not address is how metaForProperty
and eachComputedProperty
will ensure proto()
has been called first to build the inheritance chain and walk in a way such that you won't encounter duplicate props from inherited mixins and classes. This is deduping and chain walking is something that custom meta code would have to do as well.
@runspired how's Ember Data looking on this now? |
We cannot remove our use of computed and computed meta-without first eliminating our support for classic |
I believe this falls under the umbrella of #832. I'm going to close this issue to push any discussion there. Despite being closed, we will certainly use this issue for reference and to inform the future RFC. Thank you all for the discussion! |
Rendered