Skip to content

Instantly share code, notes, and snippets.

@geoffreyd
Created September 9, 2009 03:33
Show Gist options
  • Save geoffreyd/183455 to your computer and use it in GitHub Desktop.
Save geoffreyd/183455 to your computer and use it in GitHub Desktop.
What a settable and gettable computed function should look like
firstName: SC.Record.attr(String),
lastName: SC.Record.attr(String),
fullName: function(key, newValue)
{
if(newValue) {
var names = newValue.split(" ");
this.set('firstName', names[0]);
this.set('lastName', names[1]);
return this;
}
return this.get('firstName')+" "+this.get('lastName');
}.property('firstName','lastName').cacheable()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment