Last active
December 28, 2015 05:49
-
-
Save nummi/7452673 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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