2

I'd like to pull a set of data every couple of seconds (no need to discuss the pros and cons of pull vs. push here). As far as I understand ember-data that should be done with reload. Here is my app.js in which I try to trigger the pull in a ready function. But it doesn't work. How can I achieve the wanted reload?

App = Ember.Application.create({
  ready: function() {
    setInterval(function() {
      App.Switchboard.find(switchboard_id).reload
    }, 2000);
  }
});

App.Router.map(function() {
  this.resource('switchboard', { path: '/' });
});

App.SwitchboardRoute = Ember.Route.extend({
  model: function() {
    return App.Switchboard.find(switchboard_id);
  }
});

App.Store = DS.Store.extend({
  revision: 11
});

App.Switchboard = DS.Model.extend({
  name: DS.attr('string'),
});
wintermeyer
  • 8,178
  • 8
  • 39
  • 85

1 Answers1

2

Reload should work... not sure if just a typo while posting, but could it be that you need to add parenthesis to reload?

App.Switchboard.find(switchboard_id).reload()

If it doesn't work, try:

App = Ember.Application.create({
  ready: function() {
    var switchboard = App.Switchboard.find(switchboard_id);
    setInterval(function() {
      switchboard.reload();
    }, 2000);
   }
});
Teddy Zeenny
  • 3,971
  • 1
  • 17
  • 20