"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ObserveMultiStateProperties = void 0;
const tslib_1 = require("tslib");
const jsx_runtime_1 = require("react/jsx-runtime");
const react_1 = tslib_1.__importDefault(require("react"));
const DataUtilities_1 = require("@appglue/common/dist/Common/DataUtilities");
const StateManager_1 = require("@appglue/common/dist/Common/StateManager");
/**

 <ObserveMultiStateProperties
 listeners=[
 {listenTo: anobject, propertyName: 'propName' },
 {listenTo: anotherobject, propertyName: 'propName' }
 ],
 control={() => {
            return (

            );
        }}
 />
 **/
class ObserveMultiStateProperties extends react_1.default.Component {
    render() {
        return (0, jsx_runtime_1.jsx)(react_1.default.Fragment, { children: this.props.control() }, DataUtilities_1.DataUtilities.generateUniqueId());
    }
    componentDidMount() {
        if (this.props.listeners) {
            for (let l of this.props.listeners) {
                if (l.listenTo)
                    StateManager_1.StateManager.addObserver(l.listenTo, this, [l.propertyName]);
            }
        }
    }
    componentWillUnmount() {
        if (this.props.listeners) {
            for (let l of this.props.listeners) {
                if (l.listenTo)
                    StateManager_1.StateManager.removeObserver(l.listenTo, this);
            }
        }
    }
}
exports.ObserveMultiStateProperties = ObserveMultiStateProperties;
//# sourceMappingURL=ObserveMultiStateProperties.js.map