Last active
August 29, 2015 14:22
-
-
Save ksol/84503db96217655f0476 to your computer and use it in GitHub Desktop.
Ember.js: declaring a computed property/observer with ES7 decorators - http://blog.ksol.fr/ember-js-declaring-computed-property-and-observers/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import computed, { observes } from 'ember-computed-decorators'; | |
export default Ember.Object.extend({ | |
firstName: "Bob", | |
lastName: "Jones", | |
@computed('firstName', 'lastName') | |
fullName: function(firstName, lastName) { | |
return `${firstName} ${lastName}`; | |
}, | |
@observes('fullName') | |
nameHasChanged: function(fullName) { | |
console.log(`name has changed! Now it is ${'fullName'}`); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment