简体   繁体   English

Ember.RSVP.hash重新加载内部承诺

[英]Ember.RSVP.hash reload internal promises

I have an Ember.RSVP.hash object being returned from the model hook in the route object. 我有一个Ember.RSVP.hash对象从路由对象中的模型挂钩返回。 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 . 有点事情,除了我不能只调用reload因为我没有使用ember-data而是使用jQuery将属性拉入Ember.RSVP.hash So how do I reload each of the component properties? 那么,如何重新加载每个组件属性?

You can use the route's refresh method to trigger the model hook again. 您可以使用路线的refresh方法再次触发模型挂钩。

If you want to call it from the controller, you could expose the method with a route action. 如果要从控制器调用它,则可以使用route操作公开该方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM