Load ember models after view render


#1

Hey guys,

So the Router stops when loading the model untill the promise fulfills. (http://emberjs.com/guides/routing/asynchronous-routing/) Since I’m loading 2000+ models, is it possible to transition into the route, render the view and then load the models?


#2

In you route model, you can try to passe a simple model with “beforModel” , and “model” with you 2000+.


#3

Could you transition in the beforeModel hook, and then load the data in the model or afterModel hooks?


#4

All three hooks model, beforeModel and afterModel are waiting for the promise to fullfill. Right now I just know 2 possibilities. Either the hook returns something else than a function (maybe false?), which sounds ugly to me. Or you can load the data in the setupController hook, which sound more correct to me.

It might be necessary to notify the controller that holds those entries with @controllerFor(‘hugeModel’).notifyPropertyChange(‘content’). This way you are sure the view renders, when the data is loaded.


#5

Awesome! thanks a lot, will try this today :smiley: