UNPKG

igniteui-react-core

Version:
296 lines (295 loc) 10.3 kB
/* THIS INFRAGISTICS ULTIMATE SOFTWARE LICENSE AGREEMENT ("AGREEMENT") LOCATED HERE: https://www.infragistics.com/legal/license/igultimate-la https://www.infragistics.com/legal/license/igultimate-eula GOVERNS THE LICENSING, INSTALLATION AND USE OF INFRAGISTICS SOFTWARE. BY DOWNLOADING AND/OR INSTALLING AND USING INFRAGISTICS SOFTWARE: you are indicating that you have read and understand this Agreement, and agree to be legally bound by it on behalf of the yourself and your company. */ import { __extends } from "tslib"; import { Base, runOn, typeCast, markType } from "./type"; import { AsyncDataSourcePageRequest } from "./AsyncDataSourcePageRequest"; import { WeakReference } from "./WeakReference"; import { IDataSourceExecutionContext_$type } from "./IDataSourceExecutionContext"; import { LinkedList$1 } from "./LinkedList$1"; import { List$1 } from "./List$1"; /** * @hidden */ var AsyncVirtualDataSourceProviderWorker = /** @class */ /*@__PURE__*/ (function (_super) { __extends(AsyncVirtualDataSourceProviderWorker, _super); function AsyncVirtualDataSourceProviderWorker(a) { var _this = _super.call(this) || this; _this.r = new LinkedList$1(AsyncDataSourcePageRequest.$); _this.p = new List$1(AsyncDataSourcePageRequest.$, 0); _this.ac = {}; _this.i = true; _this.u = 0; _this.t = 0; _this.v = 0; _this.e = null; _this.s = -1; _this.as = null; _this.aq = null; _this.ar = null; _this.h = false; _this._isShutdown = false; _this.g = false; _this.i = true; _this.u = a.pageSizeRequested; _this.t = _this.u; _this.v = a.timeoutMilliseconds; _this.as = new WeakReference(a.pageLoaded); _this.aq = new WeakReference(a.batchCompleted); _this.ar = new WeakReference(a.executionContext); return _this; } Object.defineProperty(AsyncVirtualDataSourceProviderWorker.prototype, "tasks", { get: function () { return this.p; }, enumerable: false, configurable: true }); Object.defineProperty(AsyncVirtualDataSourceProviderWorker.prototype, "pageLoaded", { get: function () { if (this.as == null) { return null; } return this.as.c; }, enumerable: false, configurable: true }); Object.defineProperty(AsyncVirtualDataSourceProviderWorker.prototype, "batchCompleted", { get: function () { if (this.aq == null) { return null; } return this.aq.c; }, enumerable: false, configurable: true }); Object.defineProperty(AsyncVirtualDataSourceProviderWorker.prototype, "executionContext", { get: function () { if (this.ar == null) { return null; } return this.ar.c; }, enumerable: false, configurable: true }); Object.defineProperty(AsyncVirtualDataSourceProviderWorker.prototype, "actualPageSize", { get: function () { return this.t; }, set: function (a) { this.t = a; }, enumerable: false, configurable: true }); Object.defineProperty(AsyncVirtualDataSourceProviderWorker.prototype, "actualCount", { get: function () { return this.s; }, set: function (a) { this.s = a; }, enumerable: false, configurable: true }); Object.defineProperty(AsyncVirtualDataSourceProviderWorker.prototype, "actualSchema", { get: function () { return this.e; }, set: function (a) { this.e = a; }, enumerable: false, configurable: true }); Object.defineProperty(AsyncVirtualDataSourceProviderWorker.prototype, "populatedActualPageSize", { get: function () { return this.h; }, set: function (a) { this.h = a; }, enumerable: false, configurable: true }); Object.defineProperty(AsyncVirtualDataSourceProviderWorker.prototype, "isRunning", { get: function () { return this.i; }, set: function (a) { this.i = a; }, enumerable: false, configurable: true }); AsyncVirtualDataSourceProviderWorker.prototype.addPageRequest = function (a, b) { return this.addPageRequestWithRetry(a, b, 200); }; AsyncVirtualDataSourceProviderWorker.prototype.addPageRequestWithRetry = function (a, b, c) { if (this.isShutdown) { return false; } if (b == 2) { this.r.e(new AsyncDataSourcePageRequest(a, c)); } else { this.r.f(new AsyncDataSourcePageRequest(a, c)); } return true; }; AsyncVirtualDataSourceProviderWorker.prototype.removePageRequest = function (a) { var b = null; var c = this.r.c; while (c != null) { var d = c.c; if (d.index == a) { b = c; break; } c = c.a; } if (b != null) { this.r.h(b); } }; Object.defineProperty(AsyncVirtualDataSourceProviderWorker.prototype, "isShutdown", { get: function () { return this._isShutdown; }, set: function (a) { this._isShutdown = a; }, enumerable: false, configurable: true }); AsyncVirtualDataSourceProviderWorker.prototype.removeAllPageRequests = function () { this.r.g(); }; AsyncVirtualDataSourceProviderWorker.prototype.shutdown = function () { this.as = null; this.aq = null; this.ar = null; this.isShutdown = true; this.i = false; }; AsyncVirtualDataSourceProviderWorker.prototype.initialize = function () { }; AsyncVirtualDataSourceProviderWorker.prototype.getTaskDataHolder = function () { return null; }; AsyncVirtualDataSourceProviderWorker.prototype.getTasksData = function (a) { }; AsyncVirtualDataSourceProviderWorker.prototype.removeCompletedTaskData = function (a, b) { }; AsyncVirtualDataSourceProviderWorker.prototype.getCompletedTaskData = function (a, b) { }; AsyncVirtualDataSourceProviderWorker.prototype.runATask = function () { for (var a = 0; a < this.p.count; a++) { if (!this.p.item(a).taskHolder.task.isRunning && !this.p.item(a).isDone && !this.p.item(a).taskHolder.task.isCompleted && !this.p.item(a).taskHolder.task.isCancelled) { this.p.item(a).taskHolder.task.isRunning = true; this.p.item(a).taskHolder.task.run(); break; } } }; AsyncVirtualDataSourceProviderWorker.prototype.checkAndPotentiallyWaitOnTasks = function (a) { this.runATask(); for (var b = 0; b < a.length; b++) { if (a[b].isDone || a[b].taskHolder.task.isCompleted || a[b].taskHolder.task.isCancelled) { return b; } } return -1; }; AsyncVirtualDataSourceProviderWorker.prototype.doWork = function () { if (!this.g) { this.g = true; this.initialize(); } { var a = null; var b = null; var c = this.p.count; if (this.r.c != null && c < 2) { var d = this.r.c; this.r.i(); this.makeTaskForRequest(d.c, d.c.retryDelay); c = this.p.count; } if (c > 0) { a = new Array(c); for (var e = 0; e < c; e++) { a[e] = this.p.item(e); } b = this.getTaskDataHolder(); this.getTasksData(b); } if (a != null && a.length > 0) { var f = this.checkAndPotentiallyWaitOnTasks(a); if (!this.i) { return; } if (f >= 0) { var g = a[f]; this.getCompletedTaskData(b, f); this.p.remove(g); this.removeCompletedTaskData(b, f); this.processCompletedTask(g.taskHolder, g.retryDelay, g.index, b); } } else { } if (!this.i) { return; } if (this.i) { window.setTimeout(runOn(this, this.doWork), 100); } } }; AsyncVirtualDataSourceProviderWorker.prototype.makeTaskForRequest = function (a, b) { }; AsyncVirtualDataSourceProviderWorker.prototype.processCompletedTask = function (a, b, c, d) { }; AsyncVirtualDataSourceProviderWorker.prototype.retryIndex = function (a, b) { var _this = this; var c = b * 2; if (b > 20000) { this.removePageRequest(a); } if (this.ar == null) { this.shutdown(); return; } var d = typeCast(IDataSourceExecutionContext_$type, this.ar.c); if (d == null) { this.shutdown(); return; } d.executeDelayed(function () { return _this.addPageRequestWithRetry(a, 0, c); }, b); }; AsyncVirtualDataSourceProviderWorker.prototype.isLastPage = function (a) { if (this.s < 0) { return false; } if ((this.s - (a * this.t)) < this.t) { return true; } return false; }; AsyncVirtualDataSourceProviderWorker.prototype.createBatchRequest = function (a) { }; AsyncVirtualDataSourceProviderWorker.$t = markType(AsyncVirtualDataSourceProviderWorker, 'AsyncVirtualDataSourceProviderWorker'); AsyncVirtualDataSourceProviderWorker.maxSimultaneousExecutingTasks = 2; AsyncVirtualDataSourceProviderWorker.maxRetryDelay = 20000; AsyncVirtualDataSourceProviderWorker.initialRetryDelay = 200; return AsyncVirtualDataSourceProviderWorker; }(Base)); export { AsyncVirtualDataSourceProviderWorker };