Skip to content

State ​

Constructors: State.new · State.compute · Spring.new · Tween.new

Types ​

StateData type ​

luau
type StateData<T> = {
	_binds: { [T]: any },
	_bindConnection: RBXScriptConnection?,
	_boundChildren: { Instance? },
	_boundChildrenLayoutOrder: number?,
	_boundParent: Instance?,
	_connections: Type.Dict<Type.Function>,
	_computation: Type.Function?,
	_dependencies: Type.Set<State<T>>,
	_dependents: Type.Set<State<T>>,
	_tweenInfo: (TweenInfo | any)?,
	_tweenInit: any?,
	_tweenGoal: any?,
	_tweenStart: any?,
	_tweenRepeat: number?,
	_value: T,
}

State type ​

luau
type State<T> = typeof(setmetatable({} :: StateData<T>, State))

Stateful type ​

luau
type Stateful<T> = T | State<T>

Properties ​

deferUpdates ​

luau
State.deferUpdates: boolean

Functions ​

isState ​

luau
State.isState(object: any): boolean

Checks if an object is a Flux state

raw ​

luau
State.raw<T>(object: T): any

Gets the raw value of a Flux state or returns the input if it's not a state

rawVariadic ​

luau
State.rawVariadic(...: any): ...any

Gets the raw values of multiple Flux states or non-state inputs

new ​

luau
State.new<T>(initialValue: T? | Instance? | State<T>?, property: string?): State<T>

compute ​

luau
State.compute<T>(computation: () -> T): State<T>

Creates a computed state, automatically tracking dependencies

Methods ​

Connect ​

luau
State:Connect(callback: Type.Function): Type.Function

Adds a hook callback function to be called when the state changes

Destroy ​

luau
State:Destroy()

Destroys the state, clearing all dependencies and bindings