dimanche 24 janvier 2016

Ember: load models without waiting

Is it possible in Ember to load multiple models wihtout waiting for the promise to resolve and still use the afterModel hook? Currently, my code looks like this:

export default Ember.Route.extend({
  model() {
    return Ember.RSVP.hash({
      imports: this.store.findAll('import', {
        skip: 0,
        limit: 5
      }),

      latestimport: this.store.find('import', 'latest')
    });
  },

  afterModel(model) {
    ...some modifications here...
  }
}

due to the use of Ember.RSVP, the page load waits for all promises to resolve before it renders. Can I make the page render before the models are loaded? Can I then still use the afterModel hook? My point is, the data being loaded is just side information. I don't want the whole rendering process to be blocked because of that. I did not find any information in the documentation on that, although I get the feeling that the documentation is not complete at all.




Aucun commentaire:

Enregistrer un commentaire