UNPKG

@egalteam/framework

Version:

Egal

58 lines (57 loc) 2.63 kB
"use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); Object.defineProperty(exports, "__esModule", { value: true }); exports.EgalConstructor = void 0; var Model_1 = require("../Model/Model"); var Observer_1 = require("../Actions/NetworkRequests/SocketConnection/Observer"); var EgalConstructor = /** @class */ (function (_super) { __extends(EgalConstructor, _super); function EgalConstructor(modelParams) { var _this = _super.call(this, modelParams.username, modelParams.password, modelParams.modelName) || this; _this.egalObserver = Observer_1.EventObserver.getInstance(); _this.modelName = modelParams.modelName; _this.url = modelParams.url; _this.username = modelParams.username; _this.password = modelParams.password; _this.connectionType = modelParams.connectionType; _this.egalModel = new Model_1.Model(_this.username, _this.password, _this.modelName); _this.initModel(); return _this; } EgalConstructor.prototype.initModel = function () { this.egalModel.setBaseUrl(this.url); return this.egalModel; }; EgalConstructor.prototype.initModelObserver = function () { var _this = this; return new Promise(function (resolve, reject) { _this.egalObserver.subscribe(_this.modelName, function (data, actionName, modelName, actionMessage) { var receivedData; if (actionName !== 'error') { receivedData = [data[0], actionName, modelName, actionMessage]; resolve(receivedData); } else { receivedData = [data[0], actionName, modelName, actionMessage]; reject(receivedData); } }); }); }; return EgalConstructor; }(Model_1.Model)); exports.EgalConstructor = EgalConstructor;