mardi 30 décembre 2014

How do I split apart the REST calls from my IndexRoute?

I'm working on a webapp to teach myself Ember, and I've walked into one large issue:


The page halts while it is attempting to fetch json.



App.IndexRoute = Ember.Route.extend({
model: function() {

var store = this.store;
return Ember.RSVP.hash({
pokeballs: App.Pokeball.all(),
pokemon: store.find('pokemon'),
status: App.Status.all(),
levels: App.Levels
});
}
});


this.store.find('pokemon') uses the RESTAdapater, and can freeze the page from rendering anything (besides the loader) for up to 1.5 seconds.


My understanding... is the model that gets returned from the IndexRoute gets passed directly to the IndexController. I know that Ember.RSVP.hash does magic promise-like stuff to delay passing the model to the controller until everything is loaded (which is likely the core of my issue)


So my question: what is the best way to architect my IndexRoute and IndexController relationship so that the user doesn't have the page halted while the pokemon data is loaded.


Webapp Demo: http://theirondeveloper.github.io/pokemon-catch-rate


Github: https://github.com/TheIronDeveloper/pokemon-catch-rate





Aucun commentaire:

Enregistrer un commentaire