Last active
August 29, 2015 14:11
-
-
Save jnhuynh/897b566f40ce06a03ec8 to your computer and use it in GitHub Desktop.
This file contains 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
Ember.Route.extend({ | |
model: function() { | |
var promises = { | |
apiCall1: new Ember.RSVP.Promise(function(resolve, reject) { | |
// make api call 1 | |
}), | |
apiCall2: new Ember.RSVP.Promise(function(resolve, reject) { | |
// make api call 2 | |
}) | |
}; | |
// Free to do some shaping/mapping here to the primises hash properties by attaching then clauses. | |
var allMyData = new Ember.RSVP.hash(promises); | |
allMyData.then(function(results) { | |
// apiCall1 and apiCall2 will be available, except their result will be whatever your API responded with. | |
// Do what you will to shape/map your data to a model. | |
// Return it here | |
}); | |
return allMyData; | |
}, | |
setupController: function(controller, model) { | |
// by this point your model will by the result of the the shaping/mapping you did in your then resolve callback. | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment