Skip to content

Instantly share code, notes, and snippets.

@ksol
Last active August 29, 2015 14:22
Show Gist options
  • Select an option

  • Save ksol/37fedda82c6ab995b68a to your computer and use it in GitHub Desktop.

Select an option

Save ksol/37fedda82c6ab995b68a to your computer and use it in GitHub Desktop.
Ember.js: declaring a computed property/observer with prototype extension - http://blog.ksol.fr/ember-js-declaring-computed-property-and-observers/
export default Ember.Object.extend({
firstName: "Bob",
lastName: "Jones",
fullName: function() {
return `${this.get('firstName')} ${this.get('lastName')}`;
}.property('firstName', 'lastName'),
nameHasChanged: function() {
console.log(`name has changed! Now it is ${this.get('fullName')}`);
}.observes('fullName')
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment