@aurigma/design-atoms-model
Version:
Design Atoms is a part of Customer's Canvas SDK which allows for manipulating individual design elements through your code.
25 lines • 1.2 kB
JavaScript
import { ArgumentException } from "../../Exception";
import { equals } from "../../Utils/Utils";
export function PropertyChanged() {
return function (target, propertyKey) {
var privatePropKey = "_" + propertyKey;
Object.defineProperty(target, propertyKey, {
"get": function () {
return this[privatePropKey];
},
"set": function (value) {
var _a;
var type = typeof value;
if (value != null && type !== "boolean" && type !== "number" && type !== "string" && !(type === "object" && typeof value.equals === "function"))
throw new ArgumentException("PropertyChanged decorator works only for simple types or objects with equals method");
if (equals(this[privatePropKey], value))
return;
this[privatePropKey] = value;
((_a = this["_propertyChanged"]) !== null && _a !== void 0 ? _a : this["propertyChanged"]).notify(this, propertyKey);
},
configurable: true,
enumerable: true
});
};
}
//# sourceMappingURL=PropertyChanged.js.map