I would suggest using either a callback function, for a single data store, or a series of promises for multiple data stores. The former is pretty straight forward but this is how I usually handle the latter:
In this case, I'm simultaneously loading all the User Stories, Defects and Test Cases in the current scope, then when all the records have been loaded successfully, the "success" function will be called.
launch: function() {
Deft.Promise.all([
this.loadRecords('UserStory'),
this.loadRecords('Defect'),
this.loadRecords('TestCase')
]).then({
success: function(recordSets) {
// recordSets = [
// UserStoryRecords,
// DefectRecords,
// TestCaseRecords
// ];
},
failure: function() {
//Handle error loading the store here...
}
});
},
loadRecords: function(model) {
var deferred = Ext.create('Deft.Deferred');
Ext.create('Rally.data.WsapiDataStore', {
limit : Infinity,
model : model,
fetch : ['Name','ObjectID']
}).load({
callback : function(records, operation, success) {
if (operation.wasSuccessful()) {
deferred.resolve(records);
} else {
deferred.reject();
}
}
});
return deferred.promise;
}
Hope this helps!