Last active
August 29, 2015 14:22
-
-
Save ksol/d2ed38d8e40d49b8929f to your computer and use it in GitHub Desktop.
Ember.js: declaring a computed property with Ember.computed and an observer with Ember.observer - 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
| export default Ember.Object.extend({ | |
| firstName: "Bob", | |
| lastName: "Jones", | |
| fullName: Ember.computed('firstName', 'lastName', function() { | |
| return `${this.get('firstName')} ${this.get('lastName')}`; | |
| }), | |
| nameHasChanged: Ember.observer('fullName', function() { | |
| console.log(`name has changed! Now it is ${this.get('fullName')}`); | |
| }) | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment