Question

I have a Rally app that requires considerable loading time and it has some loops containing Data Stores. I need to find a condition where the app has completed loading. Once the execution of the app is complete, I want to refresh my page. Is there something like onLoad() that I can use to notify that the app has loaded completely and then I could add window.location.reload at the bottom?

Was it helpful?

Solution

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!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top