-
Notifications
You must be signed in to change notification settings - Fork 0
Closed
Labels
coreCore models and utilitiesCore models and utilitiesfeatureChanges that affect the APIChanges that affect the API
Description
/**
* A utility function to define a property on a class which must always be an instance of a certain class. Note that the private property (`#propName`) must be defined on the class first.
* @param {Object} object The object to define the property on
* @param {String} propName The name of the property to define on the object
* @param {Function} ItemModel The class to use for this property. Every time this property is set, this model will be instantiated.
* @return {Object} Returns the original object with the new property added
*/
static defineModelProp(object, propName, ItemModel) {
Object.defineProperty(object, propName, {
configurable: true,
enumerable: true,
get() {
return this[`#${propName}`];
},
set(val) {
this[`#${propName}`] = new ItemModel(val);
},
});
}Metadata
Metadata
Assignees
Labels
coreCore models and utilitiesCore models and utilitiesfeatureChanges that affect the APIChanges that affect the API