deploy: 8b6eaccd18
This commit is contained in:
@@ -1,14 +1,84 @@
|
||||
## BaseElement.setup()
|
||||
# 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.
|
||||
|
||||
## BaseElement:computed()
|
||||
## Functions
|
||||
|
||||
## BaseElement:getState()
|
||||
|Method|Returns|Description|
|
||||
|---|---|---|
|
||||
|[BaseElement:computed](#BaseElement:computed)|BaseElement|Creates a computed state
|
||||
|[BaseElement:getState](#BaseElement:getState)|any|Gets a state value
|
||||
|[BaseElement:initializeState](#BaseElement:initializeState)|BaseElement|Initializes a new state
|
||||
|[BaseElement:onStateChange](#BaseElement:onStateChange)|BaseElement|Watches for state changes
|
||||
|[BaseElement:setState](#BaseElement:setState)|BaseElement|Sets a state value
|
||||
|[BaseElement:shareState](#BaseElement:shareState)|BaseElement|Shares state between elements
|
||||
|
||||
## BaseElement:initializeState()
|
||||
## BaseElement:computed(self, key, computeFn)
|
||||
Creates a computed state that derives its value from other states
|
||||
|
||||
## BaseElement:onStateChange()
|
||||
### Parameters
|
||||
* `self` `BaseElement` The element to create computed state for
|
||||
* `key` `string` The name of the computed state
|
||||
* `computeFn` `function` Function that computes the state value
|
||||
|
||||
## BaseElement:setState()
|
||||
### Returns
|
||||
* `BaseElement` `self` The element instance
|
||||
|
||||
## BaseElement:getState(self, name)
|
||||
Gets the value of a state
|
||||
|
||||
### Parameters
|
||||
* `self` `BaseElement` The element to get state from
|
||||
* `name` `string` The name of the state
|
||||
|
||||
### Returns
|
||||
* `any` `value` The current state value
|
||||
|
||||
## BaseElement:initializeState(self, name, default, canTriggerRender?, persist?, path?)
|
||||
Initializes a new state for this element
|
||||
|
||||
### Parameters
|
||||
* `self` `BaseElement` The element to initialize state for
|
||||
* `name` `string` The name of the state
|
||||
* `default` `any` The default value of the state
|
||||
* `canTriggerRender` *(optional)* `boolean` Whether state changes trigger a render
|
||||
* `persist` *(optional)* `boolean` Whether to persist the state to disk
|
||||
* `path` *(optional)* `string` Custom file path for persistence
|
||||
|
||||
### Returns
|
||||
* `BaseElement` `self` The element instance
|
||||
|
||||
## BaseElement:onStateChange(self, stateName, callback)
|
||||
Registers a callback for state changes
|
||||
|
||||
### Parameters
|
||||
* `self` `BaseElement` The element to watch
|
||||
* `stateName` `string` The state to watch
|
||||
* `callback` `function` Called with (element, newValue, oldValue)
|
||||
|
||||
### 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 for
|
||||
* `name` `string` The name of the state
|
||||
* `value` `any` The new value for the state
|
||||
|
||||
### Returns
|
||||
* `BaseElement` `self` The element instance
|
||||
|
||||
## BaseElement:shareState(self, stateKey...)
|
||||
Shares a state with other elements, keeping them in sync
|
||||
|
||||
### Parameters
|
||||
* `self` `BaseElement` The source element
|
||||
* `stateKey` `string` The state to share
|
||||
* `...` *(vararg)* `BaseElement` The target elements to share with
|
||||
|
||||
### Returns
|
||||
* `BaseElement` `self` The source element
|
||||
|
||||
## BaseElement:shareState()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user