Reputation: 2271
I am very new to Ember.js and read its documentation and also following given starting example. They use property
method in computed properties and pass a model property (some time with @each). I don't know why they use it. Here duration is made available using this.get('model.duration')
than why .property('model.duration')
App.SongController = Ember.ObjectController.extend({
duration: function() {
var duration = this.get('model.duration'),
minutes = Math.floor(duration / 60),
seconds = duration % 60;
return [minutes, seconds].join(':');
}.property('model.duration')
});
Upvotes: 1
Views: 1170
Reputation: 3872
The Computed Property .property()
is cached by default. ie., the value is not computed everytime when you call the property.
To compute the value of the computed property again when any of its dependent key changes, we need to specify its dependencies...
However we can turn off the cacheable option by using .property().volatile()
Refer Ember API
Upvotes: 2