all files / common/model/ data.js

95.83% Statements 23/24
100% Branches 6/6
88.89% Functions 8/9
95.83% Lines 23/24
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36   8465×   8465× 8465×   27× 27×   28× 28×         27×          
define(["require", "exports", "@syncfusion/ej2-data"], function (require, exports, ej2_data_1) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var Data = (function () {
        function Data(dataSource, query) {
            this.initDataManager(dataSource, query);
        }
        Data.prototype.initDataManager = function (dataSource, query) {
            this.dataManager = dataSource instanceof ej2_data_1.DataManager ? dataSource : new ej2_data_1.DataManager(dataSource);
            this.query = query instanceof ej2_data_1.Query ? query : new ej2_data_1.Query();
        };
        Data.prototype.generateQuery = function () {
            var query = this.query.clone();
            return query;
        };
        Data.prototype.getData = function (dataQuery) {
            var _this = this;
            if (this.dataManager.ready) {
                var dataManagerDeferred_1 = new ej2_data_1.Deferred();
                var ready = this.dataManager.ready;
                ready.then(function () {
                    _this.dataManager.executeQuery(dataQuery).then(function (result) {
                        dataManagerDeferred_1.resolve(result);
                    });
                }).catch(function (e) { dataManagerDeferred_1.reject(e); });
                return dataManagerDeferred_1.promise;
            }
            else {
                return this.dataManager.executeQuery(dataQuery);
            }
        };
        return Data;
    }());
    exports.Data = Data;
});