0

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?

HypeXR
  • 711
  • 2
  • 6
  • 19
  • 1
    Ember-Model uses Ember's object model, so it definitely supports computed properties. Are you sure that the value itself isn't updating? Maybe the value is but your template isn't. Try a `console.log` in one of the properties statement to see if you get anything. – GJK Apr 11 '14 at 18:44
  • It's working, since I wasn't using the updated value and the result of the computed value was not changing it threw me off. Thanks! – HypeXR Apr 11 '14 at 19:23

1 Answers1

0

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

HypeXR
  • 711
  • 2
  • 6
  • 19