import { coerceBooleanProperty } from '../util/coerce';
/**
 * decorate input properties with get and set method, it does two things:
 *
 * - enable boolean input property shorthand
 * - enable listening input property change
 *
 * @param {boolean?} isBooleanProperty - whether the property is a boolean property like disabled
 * @param {boolean?} force force trigger property event(only when the event is defined)
 */
export function OnChange(isBooleanProperty, force) {
    var sufix = 'Change';
    return function OnChangeHandler(target, propertyKey) {
        var _key = "__" + propertyKey + "Value";
        Object.defineProperty(target, propertyKey, {
            get: function () {
                return this[_key];
            },
            set: function (value) {
                var prevValue = this[_key];
                this[_key] = isBooleanProperty ? coerceBooleanProperty(value) : value;
                if ((prevValue !== this[_key] || force) && this[propertyKey + sufix]) {
                    this[propertyKey + sufix].emit(this[_key]);
                }
            }
        });
    };
}
//# sourceMappingURL=decorators.js.map