src/common/property-observer/index.js
function observeRoot(widget, attributes, callback, skipSetState) {
    attributes.forEach(attribute => {
        Object.defineProperty(widget.el, attribute, {
            get() {
                return widget.state[attribute];
            },
            set(value) {
                if (!skipSetState) {
                    widget.setState(attribute, value);
                }
                if (callback) {
                    callback(value);
                }
            }
        });
    });
}
function observeRoot(widget, attributes, callback, skipSetState) {
    attributes.forEach(attribute => {
        Object.defineProperty(widget.el, attribute, {
            get() {
                return widget.state[attribute];
            },
            set(value) {
                if (!skipSetState) {
                    widget.setState(attribute, value);
                }
                if (callback) {
                    callback(value);
                }
            }
        });
    });
}
function observeRoot ( widget , attributes , callback , skipSetState ) { attributes . forEach ( attribute => { Object . defineProperty ( widget . el , attribute , { get ( ) { return widget . state [ attribute ] ; } , set ( value ) { if ( ! skipSetState ) { widget . setState ( attribute , value ) ; } if ( callback ) { callback ( value ) ; } } } ) ; } ) ; }
For each attribute, define getter and setter on root DOM element of the widget
@param {Object} widget
@param {Array} attributes
@param {Function} callback
@param {Boolean} skipSetState: useful for handling setState in your component, rather than here
For each attribute define getter and setter on root DOM element of the widget