Getting started
VideState validates source values and manages their state changes. Vide creates the UI Instances; VideState owns the values those Instances bind to.
Not tested for production
VideState has only been benchmarked in Roblox Studio, and it has not been tested in production. Use it wisely: measure it in your own project, especially with many handlers or transitions running at once, before you depend on it. See Performance.
Install
VideState is one package, on Ember, pesde, and Wally. Its only dependency is Vide, which is installed with it.
embr add idemandsky/videstatepesde add idemandsky/videstate[dependencies]
VideState = "idemandsky/videstate@0.9.1"Require the library
const VideState = require("@VideState")Create a rule and handler
Create a Vide source for each field in each state. A handler then follows the active state's sources.
const VideState = require("@VideState")
const Vide = require("@packages/Vide")
const schemas = VideState.schemas
const rules = VideState.rules
local PanelRule = rules.dynamic(schemas.new({
visible = schemas.boolean(),
order = schemas.integer({ min = 0 }),
}), { name = "Panel" })
local panel = PanelRule.new({
Idle = { visible = Vide.source(false), order = Vide.source(0) },
Active = { visible = Vide.source(true), order = Vide.source(1) },
}, "Idle")
panel.setState("Active")Pass panel.sources.visible to any Vide property to bind it. Setting a new state switches which sources the handler reads, so those bindings update automatically.
Next steps
- Schemas lists every builder and its options.
- Rules covers rule metadata and typing.
- Handlers covers states, sources, and errors.
- Transitions covers
onChangeandonTransition. - Info looks up registered rules while debugging.