UNPKG

ngx-decorate

Version:

Useful decorators for Angular 2 and above

37 lines 1.22 kB
/** * Call .markForCheck() on the change detector ref whenever this property is written to. * * @param propName Property at which the change detector can be found * @param conf Optional configuration */ export function CdrProp(propName, conf) { if (conf === void 0) { conf = {}; } return function (target, key) { var _a; var sym = Symbol("value:" + key.toString()); var defaultDescriptor = { configurable: true, enumerable: true }; Object.defineProperties(target, (_a = {}, _a[sym] = { configurable: false, enumerable: false, value: conf.default || target[key], writable: true }, _a[key] = Object.assign(defaultDescriptor, conf.desc || {}, { get: function () { return this[sym]; }, set: function (v) { this[sym] = v; if (!conf.destroyed || !this[conf.destroyed]) { this[propName].markForCheck(); } } }), _a)); }; } //# sourceMappingURL=CdrProp.js.map