1
votes

I'm having trouble getting a computed property to recompute.

My route looks like this:

App.DiagnosticsRoute = Ember.Route.extend({
  model: function() {
      return Ember.RSVP.hash({
          lights: this.store.find('light'),
          networkInterfaces: this.store.find('networkInterface'),
          networks: this.store.find('network', { diagnostics: "1"})
      });
  },
});

My controller has the following computed property:

  networksCount: function() {
    var networks_count = this.get('networks.length');
    if (0 == networks_count) return '(All Clear)';
    return networks_count;

  }.property('networks.length')

I'd like to poll the server to refresh the network collection. I've placed store.find('network') elsewhere in the App, and though the chrome ember extension shows the data is loaded into the store, the above computed property doesn't update. AdapterPopulatedRecordArray doesn't implement reload. How can I get the property to recompute??

1
Can you provide a jsbin with a working example of the problem?SimonW

1 Answers

0
votes

I found one pretty good solution via: How to update Ember's model periodically (such as in setInterval)?

  actions: {
    update: function() {
      this.set('networks',this.store.find('network'));
  }
  },
  networksCount: function() {
    var networks_count = this.get('networks.length');
    if (0 == networks_count) return '(All Clear)';
    return networks_count;

  }.property('networks.length')