@ngreatorex/homie-device
Version:
Homie Device for NodeJS
29 lines • 1.18 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const HomieTopologyBase_1 = __importDefault(require("./HomieTopologyBase"));
class HomieTopologyWithConfiguration extends HomieTopologyBase_1.default {
constructor(config) {
super(config.name, config.friendlyName);
this.configurable$ = true;
this.onConnect = () => {
this.configurable$ = false;
super.onConnect();
if (!Object.isFrozen(this.config$)) {
this.logger.debug("freezing configuration");
this.config$ = Object.freeze(this.config$);
}
};
this.config$ = config;
}
get config() { return this.config$; }
assertConfigurable() {
if (!this.configurable$) {
throw new Error(`This ${this.constructor.name} is no longer configurable. All configuration must occur prior to connecting.`);
}
}
}
exports.default = HomieTopologyWithConfiguration;
//# sourceMappingURL=HomieTopologyWithConfiguration.js.map