Uh oh!
There was an error while loading. Please reload this page.
RFC: Improved CP Syntax - #11
Conversation
jayphelps
commented
Oct 31, 2014
No mention of |
stefanpenner
commented
Oct 31, 2014
@jayphelps I suspect it will continue to work for the I suppose the explicitly writable case without a pojo, just a FN, on set, should check arity and either call FN with 2 arguments (like today's setter CP) or stomp the CP. This should be handled by my compatibility mode and I suspect this will be deprecated for 2.0 |
rwjblue
commented
Oct 31, 2014
Very happy about this proposal. 👍 |
49a6001 to
3ff96daCompare3ff96da to
1ab7ff4Comparecibernox
commented
Nov 2, 2014
I don't know how I missed this. There is something I can do to help from ember-cpm? Maybe betatest this syntax now? functionEmberCPM_computed(){varargs=Array.prototype.slice(arguments,0,-2);varopts=Array.prototype.slice(arguments.length-1)args.push(function(){if(arguments.length>1){opts.set.apply(this,arguments);}else{opts.get.apply(this,arguments);}});returnEmber.computed(this,args)} |
stefanpenner
commented
Nov 2, 2014
Honestly you could just pr it to ember :) let iterate in a pr and release as soon as it's good :) |
mike-north
commented
Nov 3, 2014
I've got a PR in the works. Should be opening it in a couple of hours |
mike-north
commented
Nov 3, 2014
Ok, I've got something working now :) One part of the RFC that's going to cause some problems for people (myself included)
I take this to mean that if I'd written something like this today (which results in a writable computed property) varMyType=Ember.Object.extend({a: 6,b: 12,half: Ember.computed('a','b',function(key,val,oldVal){if(arguments.length<2){return0.5*(this.get('a')+this.get('b'));}else{this.setProperties({a: val/2,b: val/2});returnval;}})});Once this proposed improvement is made, the function (3rd argument passed to Is there any reason we can't continue to support both? |
knownasilya
commented
Nov 4, 2014
@igorT This could be a good replacement for |
lukemelia
commented
Nov 4, 2014
@truenorth agreed re: not breaking the existing setter approach. deprecating it would reasonable/helpful if possible. |
amiel
commented
Nov 4, 2014
Yes please. I love this idea!! |
cowboy
commented
Dec 9, 2014
I'd much rather see this, a la ember-auto, because as it currently stands, it's very repetitive to specify the dependent properties both in the call to fullName: Ember.computed('firstName','lastName',{get: function(firstName,lastName){returnfirstName+' '+lastName;},// ...}); |
jayphelps
commented
Dec 9, 2014
Dogpile! https://github.com/jayphelps/ember-computed-smart-property fullName: Ember.computed.smartProperty({get: function(){returnthis.get('firstName')+' '+this.get('lastName');}}) |
cowboy
commented
Dec 9, 2014
To support this functionality with less code for properties that are only getters and not setters, but in a backwards-compatible way, maybe an argument could be added to the fullName: function(firstName,lastName){returnfirstName+' '+lastName;}.property('firstName','lastName',{args: true}),Or even a whole new fullName: function(firstName,lastName){returnfirstName+' '+lastName;}.properties('firstName','lastName'),Or the way ember-computed-smart-property does it, which is also awesome! |
stefanpenner
commented
Dec 9, 2014
fullName: function(firstName,lastName){returnfirstName+' '+lastName;}.properties('firstName','lastName'),is interesting when a 1:1 between DK and inputs exists forsure. This type of CP macro would make a great community add-on. The specific RFC existed to primarily remove the arity check from the current CP's as that is obviously mega terrible. |
awj
commented
Apr 7, 2015
I like the general idea, but am concerned about it creating such a difference between I'm not sure how That concern aside, 👍 |
cibernox
commented
Apr 7, 2015
@awj The |

No description provided.