@webex/webex-core
Version:
Plugin handling for Cisco Webex
98 lines (93 loc) • 2.94 kB
JavaScript
;
var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/define-property");
var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequireDefault");
_Object$defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/classCallCheck"));
var _createClass2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/createClass"));
var _constants = require("../constants");
/**
* The state of a specific catalog to be used by {@link ServiceState}.
*
* @typedef {Record<string, boolean>} CatalogState
* @property {boolean} CatalogState.collecting - If the catalog is collecting.
* @property {boolean} CatalogState.ready - If the catalog is ready.
*/
/**
* @class
* @classdesc - Manages the state of the service catalogs for a webex instance.
*/
var ServiceState = exports.default = /*#__PURE__*/function () {
/**
* Generate a new {@link ServiceState}.
*
* @public
* @constructor
* @memberof ServiceState
*/
function ServiceState() {
var _this = this;
(0, _classCallCheck2.default)(this, ServiceState);
// Iterate over the possible catalog names and generate their states.
_constants.SERVICE_CATALOGS.forEach(function (catalog) {
_this[catalog] = ServiceState.generateCatalogState();
});
}
/**
* Set a catalog to be collecting or not.
*
* @public
* @memberof ServiceState
* @param {string} catalog - Catalog to target.
* @param {boolean} collecting - If the target is collecting or not.
* @returns {undefined}
*/
(0, _createClass2.default)(ServiceState, [{
key: "setCollecting",
value: function setCollecting(catalog, collecting) {
// Validate that the catalog state exists.
if (this[catalog]) {
// Set the 'collecting' status of the catalog state.
this[catalog].collecting = collecting;
}
}
/**
* Set a catalog to be ready or not.
*
* @public
* @memberof ServiceState
* @param {string} catalog - Catalog to target.
* @param {boolean} ready - If the target is ready or not.
* @returns {undefined}
*/
}, {
key: "setReady",
value: function setReady(catalog, ready) {
// Validate that the catalog state exists.
if (this[catalog]) {
// Set the 'ready' status of the catalog state.
this[catalog].ready = ready;
}
}
/**
* Generate a {@link CatalogState}.
*
* @public
* @static
* @memberof ServiceState
* @returns {CatalogState} - The generated {@link CatalogState}.
*/
}], [{
key: "generateCatalogState",
value: function generateCatalogState() {
return {
collecting: false,
ready: false
};
}
}]);
return ServiceState;
}();
//# sourceMappingURL=service-state.js.map