import{_ as a,a as t,b as s,ag as l}from"./chunks/framework.BcrMLAmg.js";const u=JSON.parse('{"title":"BaseFrame","description":"","frontmatter":{},"headers":[],"relativePath":"references/plugins/state.md","filePath":"references/plugins/state.md","lastUpdated":1757840145000}'),r={name:"references/plugins/state.md"};function n(o,e,d,i,c,m){return s(),t("div",null,e[0]||(e[0]=[l('
Extends: Container
| Method | Returns | Description |
|---|---|---|
| BaseFrame:initializeState | BaseFrame | Initializes a new state |
Initializes a new state for this element
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 persistenceBaseFrame self The element instanceThis is the state plugin. It provides a state management system for UI elements with support forpersistent states, computed states, and state sharing between elements.
| Method | Returns | Description |
|---|---|---|
| BaseElement:setState | BaseElement | Sets a state value |
| BaseElement:getState | any | Gets a state value |
| BaseElement:onStateChange | BaseElement | Watches for state changes |
| BaseElement:removeStateChange | BaseElement | Removes a state change observer |
| BaseElement:bind | BaseElement | Binds a property to a state |
Sets the value of a state
self BaseElement The element to set state forname string The name of the statevalue any The new value for the stateBaseElement self The element instanceGets the value of a state
self BaseElement The element to get state fromname string The name of the stateany value The current state valueRegisters a callback for state changes
self BaseElement The element to watchstateName string The state to watchcallback function Called with (element, newValue, oldValue)BaseElement self The element instanceRemoves a state change observer
self BaseElement The element to remove observer fromstateName string The state to remove observer fromcallback function The callback function to removeBaseElement self The element instanceBinds a property to a state
self BaseElement The element to bindpropertyName string The property to bindstateName string The state to bind to (optional, uses propertyName if not provided)BaseElement self The element instance