is possible in ember load multiple models wihtout waiting promise resolve , still use aftermodel hook? currently, code looks 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 use of ember.rsvp, page load waits promises resolve before renders. can make page render before models loaded? can still use aftermodel hook? point is, data being loaded side information. don't want whole rendering process blocked because of that. did not find information in documentation on that, although feeling documentation not complete @ all.
please use following approach:
setupcontroller(controller, model) { this._super(controller, model); ember.rsvp.hash({ imports: this.store.findall('import', { skip: 0, limit: 5 }), latestimport: this.store.find('import', 'latest') }).then(results => { // ...some modifications here... controller.set('model', results); }); }
- it shouldn't block rendering.
- you can still apply modifications data.
- you can still access data in template
model.imports
,model.latestimport
.
Comments
Post a Comment