Rally App onLoad

时间:2014-02-20 13:45:26

标签: extjs rally

我有一个需要大量加载时间的Rally应用程序,它有一些包含数据存储的循环。我需要找到应用程序已完成加载的条件。一旦应用程序的执行完成,我想刷新我的页面。是否有类似onLoad()的东西我可以用来通知应用程序已完全加载,然后我可以在底部添加window.location.reload

1 个答案:

答案 0 :(得分:4)

我建议使用回调函数,单个数据存储,或多个数据存储的一系列承诺。前者非常简单,但这就是我通常处理后者的方式:

在这种情况下,我同时加载当前作用域中的所有用户故事,缺陷和测试用例,然后当 all 成功加载记录时,“成功”功能将是调用。

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;
}

希望这有帮助!