samedi 20 février 2016

Ember.RSVP.hash reload internal promises

I have an Ember.RSVP.hash object being returned from the model hook in the route object. However, I'd like to periodically pull the data from the server and "refresh" or reload all the data with the new data from the server. How can this be done? Say it looks something like this:

model: function(params) {

        return new Ember.RSVP.hash({
            firstProp: Ember.$.getJSON(baseURL + 'firstProp/'),
            secondProp: Ember.$.getJSON(baseURL + 'secondProp/'),
            thirdProp: Ember.$.getJSON(baseURL + 'thirdProp/'),
        });
    }

and I want to be able to do something like

poll: function() {
      var _this = this;
      Ember.run.later( function() {
         _this.reload(); 
         _this.poll();
      }, 500);
   }.observes('didLoad')

sort of thing, except I can't just call reload because I'm not using ember-data but rather using jQuery to pull the properties into an Ember.RSVP.hash. So how do I reload each of the component properties?




Aucun commentaire:

Enregistrer un commentaire