import { jsx as _jsx } from "react/jsx-runtime";
import React from "react";
import { DataUtilities } from "../../Common/DataUtilities";
import { StateManager } from "./StateManager";
/**

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

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