Skip to content

Instantly share code, notes, and snippets.

@nummi
Last active December 28, 2015 05:49
Show Gist options
  • Select an option

  • Save nummi/7452673 to your computer and use it in GitHub Desktop.

Select an option

Save nummi/7452673 to your computer and use it in GitHub Desktop.
App.OldAndBustedRoute = App.Route.extend({
/*
Calling find from the model hook will block page rendering until (I think) the promise is fulfilled.
*/
model: function(params) {
return this.store.find('collection', params.collection_id);
},
setupController: function(controller, model) {
controller.set('isLoading', true);
model.get('products').then(function() {
controller.set('isLoading', false);
});
}
});
App.NewHawtnessRoute = App.Route.extend({
/*
Returning the params will cause the page to render immediately.
The downside is an ugly looking setupController.
At least it increases perceived speed.
*/
model: function(params) {
return params;
},
setupController: function(controller, params) {
controller.set('isLoading', true);
this.store.find('collection', params.collection_id).then(function(model) {
controller.set('model', model);
model.get('products').then(function() {
controller.set('isLoading', false);
});
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment