"use strict";
var __extends = (this && this.__extends) || function (d, b) {
    for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
    function __() { this.constructor = d; }
    d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var rxjs_1 = require("rxjs");
var dataSourceBaseOld_service_1 = require("./dataSourceBaseOld.service");
var AsyncDataSource = (function (_super) {
    __extends(AsyncDataSource, _super);
    function AsyncDataSource(getDataSet, dataSourceProcessor, array) {
        var _this = _super.call(this, dataSourceProcessor, array) || this;
        _this.synchronizedRequests = new rxjs_1.Subject();
        _this.getDataSet = getDataSet;
        _this.reloaded = new rxjs_1.Subject();
        _this.synchronizedRequests.switch().subscribe(function (data) { return _this.resolveReload(data); });
        return _this;
    }
    AsyncDataSource.prototype.reload = function () {
        this.dataSet = null;
        this.rawDataSet = null;
        this.loadingDataSet = true;
        this.synchronizedRequests.next(rxjs_1.Observable.from(this.getDataSet(this.getParams())));
    };
    AsyncDataSource.prototype.resolveReload = function (data) {
        this.loadingDataSet = false;
        this.rawDataSet = data;
        this.processData();
        this.reloaded.next(null);
        this.redrawing.next(null);
        this.changed.next(null);
    };
    // override with params for getDataSet
    AsyncDataSource.prototype.getParams = function () {
        return null;
    };
    return AsyncDataSource;
}(dataSourceBaseOld_service_1.DataSourceBaseOld));
exports.AsyncDataSource = AsyncDataSource;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXN5bmNEYXRhU291cmNlLnNlcnZpY2UuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyJhc3luY0RhdGFTb3VyY2Uuc2VydmljZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7QUFBQSw2QkFBMkM7QUFNM0MseUVBQWdFO0FBZWhFO0lBQWdELG1DQUE0QjtJQUszRSx5QkFBWSxVQUF1QyxFQUMvQyxtQkFBNEMsRUFDNUMsS0FBNEI7UUFGaEMsWUFHQyxrQkFBTSxtQkFBbUIsRU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