PropertySystem
PropertySystem is a class that allows Elements to have properties that can be observed and updated.It also allows for properties to have custom getters and setters. This is the base system for all Elements.
Functions
| Method | Returns | Description |
|---|---|---|
| PropertySystem.addSetterHook | - | Adds a setter hook to the PropertySystem |
| PropertySystem.defineProperty | - | Defines a property for an element class |
| PropertySystem.combineProperties | - | Combines multiple properties |
| PropertySystem.blueprint | table | Creates a blueprint of an element class |
| PropertySystem.createFromBlueprint | table | Creates an element from a blueprint |
| PropertySystem:__init | table | Initializes the PropertySystem |
| PropertySystem:_updateProperty | table | Update call for a property |
| PropertySystem:observe | table | Observers a property |
| PropertySystem:removeObserver | table | Removes an observer from a property |
| PropertySystem:removeAllObservers | table | Removes all observers from a property |
| PropertySystem:instanceProperty | table | Adds a property to the PropertySystem on instance level |
| PropertySystem:removeProperty | table | Removes a property from the PropertySystem |
| PropertySystem:getPropertyConfig | table | Gets a property configuration |
PropertySystem.addSetterHook(hook)
Adds a setter hook to the PropertySystem. Setter hooks are functions that are called before a property is set.
Parameters
hookfunctionThe hook function to add
PropertySystem.defineProperty(class, name, config)
Defines a property for an element class
Parameters
classtableThe element class to define the property fornamestringThe name of the propertyconfigtableThe configuration of the property
PropertySystem.combineProperties(class, name)
Combines multiple properties into a single getter and setter
Parameters
classtableThe element class to combine the properties fornamestringThe name of the combined property
PropertySystem.blueprint(elementClass)
Creates a blueprint of an element class with all its properties
Parameters
elementClasstableThe element class to create a blueprint from
Returns
tableblueprintA table containing all property definitions
PropertySystem.createFromBlueprint(elementClass, blueprint)
Creates an element from a blueprint
Parameters
elementClasstableThe element class to create from the blueprintblueprinttableThe blueprint to create the element from
Returns
tableelementThe created element
PropertySystem:__init()
Initializes the PropertySystem IS USED INTERNALLY
Returns
tableselfThe PropertySystem
PropertySystem:_updateProperty(name, value)
Update call for a property IS USED INTERNALLY
Parameters
namestringThe name of the propertyvalueanyThe value of the property
Returns
tableselfThe PropertySystem
PropertySystem:observe(name, callback)
Observers a property
Parameters
namestringThe name of the propertycallbackfunctionThe callback function to call when the property changes
Returns
tableselfThe PropertySystem
PropertySystem:removeObserver(name, callback)
Removes an observer from a property
Parameters
namestringThe name of the propertycallbackfunctionThe callback function to remove
Returns
tableselfThe PropertySystem
PropertySystem:removeAllObservers(name?)
Removes all observers from a property
Parameters
name(optional)stringThe name of the property
Returns
tableselfThe PropertySystem
PropertySystem:instanceProperty(name, config)
Adds a property to the PropertySystem on instance level
Parameters
namestringThe name of the propertyconfigtableThe configuration of the property
Returns
tableselfThe PropertySystem
PropertySystem:removeProperty(name)
Removes a property from the PropertySystem on instance level
Parameters
namestringThe name of the property
Returns
tableselfThe PropertySystem
PropertySystem:getPropertyConfig(name)
Gets a property configuration
Parameters
namestringThe name of the property
Returns
tableconfigThe configuration of the property