Search code examples
javascriptember.jsember-model

Ember: Does ember-model allow binding computed values using .properties(...)


I'm trying to get a computed value in my model to update using the .property('key') syntax. My model is like:

App.Camera = Em.Model.extend({
    id: attr(),
    uid: attr(),
    name: attr(),
    type: attr(),
    refresh: attr(),

    thumbnailUrl384x216: function() {
        return '%@/devices/%@/thumbnail?width=384&height=216'.fmt(apiBaseUri, this.get('uid'));
    }.property('uid', 'refresh'),

    thumbnailUrlFull: function() {
        return '%@/devices/%@/thumbnail?width=1280&height=720'.fmt(apiBaseUri, this.get('uid'));
    }.property('uid', 'refresh')
});

In my camera route I am modifying the refresh variable on an interval, but it is not causing the thumbnailUrl's to update. Am I doing something wrong or does ember-model not support the .property() feature.

I'm able to use the refresh attribute in my template and I see it updating. Any ideas?


Solution

  • The computed value was not updating because I wasn't using the changing refresh value in the computation. Adding that fixed it.