-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Add deprecation for old usages of cachable and readOnly in CPs #9489
Add deprecation for old usages of cachable and readOnly in CPs #9489
Conversation
64de7e4
to
c60c5c6
Compare
Can you add a test that uses Can you also deprecate passing |
@@ -145,6 +145,7 @@ var ComputedPropertyPrototype = ComputedProperty.prototype; | |||
@chainable |
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.
Needs to be marked as @deprecated
also.
I'm on it. |
b08e76d
to
9f48f03
Compare
All done. You mentioned in the former PR that readOnly should be deprecated too. I can deprecate passing opts.readOnly in the constructor, but there is no equivalent of Because you can pass |
Forget my last comment. I misread your comment in the last PR. |
@@ -120,7 +120,8 @@ function ComputedProperty(func, opts) { | |||
this._suspended = undefined; | |||
this._meta = undefined; | |||
|
|||
this._cacheable = (opts && opts.cacheable !== undefined) ? opts.cacheable : true; | |||
Ember.deprecate("Passing opts.cacheable to the CP constructor is deprecated. Invoke `volatile()` on the CP instead.", !opts || !opts.hasOwnProperty('cacheable')); | |||
this._cacheable = (opts && opts.cacheable !== undefined) ? opts.cacheable : true; // TODO: Set alwats to `true` once this deprecation is gone. |
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.
s/alwats/always/
9f48f03
to
3815441
Compare
ComputedProperty.cacheable()
.
Added readOnly deprecation too. |
There are a few failures, when running with this query-string. |
Fixed. Now I invoke Should I rebase? |
@krisselden r? |
@cibernox - Yes, if you could squash and rebase, that would be great. |
904dfc1
to
c56e38c
Compare
Rebased. Done here. |
@cibernox - Thank you. I think we are waiting for @krisselden to have a chance to review before merging. |
👍 |
This seems good to me. @stefanpenner / @krisselden - Any tweaks or objections? |
For the record, I have implemented emberjs/rfcs#11 on top of this. |
@krisselden / @stefanpenner Ping here. #9527 is done and based on this one. |
c56e38c
to
56f1b57
Compare
Rebased |
so far looks good. @krisselden your eyes would be good |
Another ping to @krisselden ! |
Thanks! |
*/ | ||
ComputedPropertyPrototype.cacheable = function(aFlag) { | ||
Ember.deprecate('ComputedProperty.cacheable() is deprecated. All computed properties are cacheable by default. Use `.volatile()` if you want to mark a computed property as not cacheable.'); |
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.
.volatile is more like manual, it may prevent the internal CP caching, but it has no effect on downstream caching that happens in the view layer for example. It is generally used for properties that are manually notified and delegated, like array.length. It really should be an extremely rare occurrence in an app.
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.
So what do you suggest then? Not mention volatile at all?
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 suspect he would prefer you don't mention it at all.
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.
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.
@cibernox lol, i see we have driven you to insanity with our slowness. Sorry, we will not let this happen again.
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.
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.
👍
56f1b57
to
bb8d206
Compare
* Passing opts.cacheable to the constructor of ComputedProperty is deprecated * Passing opts.readOnly to the constructor of ComputedProperty is deprecated * Invoking `cacheable` in a computed property is preprecated. * Invoking `readOnly` with aany params in a computed property is deprecated. * Make InjectedProperty inherit `readOnly` from CPs prototype
bb8d206
to
dd15598
Compare
I would say that NOW its ready to merge. |
@stefanpenner ping! |
Add deprecation for old usages of cachable and readOnly in CPs
👍 sorry, i have meant to review this sooner but i have been sick in bed for the last few days. |
Don't worry |
cacheable
in a computed property is preprecated.readOnly
with aany params in a computed property is deprecated.-- UPDATE --
After reading #9290 and emberjs/rfcs#12, seems that this PR is the first step to make CP read only by default.
Steps done in this PR:
cacheable
orreadOnly
to the constructor. No extrictly necessary, but is not used anywhere in the code since 2012 and simplifies things.cacheable()
andreadOnly()
. Are the default.Steps pending:
Ember.computed
. If is arity <=1, create only a setter. If has arity > 1, assign the same function to getter and setter. Passing an object also works. No deprecations yet.{get, set}
instead.writable
and/oroverridable
and determina default values as explained in the code example above.This steps don't need to happen in this PR. I fact I would merge things one step at a time.