BaseElement
This is the state plugin. It provides a state management system for UI elements with support for persistent states, computed states, and state sharing between elements.
Functions
Method | Returns | Description |
---|---|---|
BaseElement:bind | BaseElement | |
BaseElement:computed | - | |
BaseElement:getState | any | Gets a state value |
BaseElement:onStateChange | BaseElement | Watches for state changes |
BaseElement:removeStateChange | BaseElement | Removes a state change observer |
BaseElement:setState | BaseElement | Sets a state value |
BaseElement:bind(self, propertyName, stateName)
Binds a property to a state
Parameters
self
BaseElement
The element to bindpropertyName
string
The property to bindstateName
string
The state to bind to (optional, uses propertyName if not provided)
Returns
BaseElement
self
The element instance
BaseElement:computed()
BaseElement:getState(self, name)
Gets the value of a state
Parameters
self
BaseElement
The element to get state fromname
string
The name of the state
Returns
any
value
The current state value
BaseElement:onStateChange(self, stateName, callback)
Registers a callback for state changes
Parameters
self
BaseElement
The element to watchstateName
string
The state to watchcallback
function
Called with (element, newValue, oldValue)
Returns
BaseElement
self
The element instance
BaseElement:removeStateChange(self, stateName, callback)
Removes a state change observer
Parameters
self
BaseElement
The element to remove observer fromstateName
string
The state to remove observer fromcallback
function
The callback function to remove
Returns
BaseElement
self
The element instance
BaseElement:setState(self, name, value)
Sets the value of a state
Parameters
self
BaseElement
The element to set state forname
string
The name of the statevalue
any
The new value for the state
Returns
BaseElement
self
The element instance
BaseFrame : Container
Functions
Method | Returns | Description |
---|---|---|
BaseFrame.setup | - | |
BaseFrame:initializeState | BaseFrame | Initializes a new state |
BaseFrame.setup()
BaseFrame:initializeState(self, name, default, persist?, path?)
Initializes a new state for this element
Parameters
self
BaseFrame
The element to initialize state forname
string
The name of the statedefault
any
The default value of the statepersist
(optional)boolean
Whether to persist the state to diskpath
(optional)string
Custom file path for persistence
Returns
BaseFrame
self
The element instance