I'm trying to have specific instructions running when my data coming from the server via Ember data is fully loaded. I want to redirect the ember app to a different route following the number of items the server returned.
I have tried to use the promise returned by the findAll()
method, but the function gets fired too soon as the data has not been loaded yet. Then I tried to use the event didLoad
but it never gets fired.
Has anyone any thoughts for this ?
Thanks !
1
votes
1 Answers
0
votes
The records should be available by the time the promise is resolved if you are following the pattern below. Additionally the afterModel hook in a route will have the model resolved. Now this is a little different if you have async relationships or some other structure, if that's the case you need to specify more information.
var blah = this.get('store').find('apples');
blah.then(function(records){
//records are loaded at this point.
console.log("Loaded " + records.get('length') + " records");
});