February 2016
Beginner to intermediate
308 pages
5h 46m
English
Observers are fundamental to the Ember object model. In the next recipe, we'll take our light example, add an observer, and see how it operates.
isOnChanged. This will only trigger when the isOn property changes:const Light = Ember.Object.extend({
isOn: false,
color: 'yellow',
age: null,
description: Ember.computed('isOn','color',function() {
return 'The ' + this.get('color') + 'light is set to ' + this.get('isOn')
}),
fullDescription: Ember.computed ('description','age',function() {
return this.get('description') + ' and the age is ' + this.get('age')
}),
desc: Ember.computed.alias('description'),
isOnChanged: Ember.observer('isOn',function() {Read now
Unlock full access