State
@Model class State<T> : Framed
kotlin.Any | |
↳ | androidx.compose.State |
The State class is an @Model class meant to wrap around a single value. It is used in the
+state
and +stateFor
effects.
Summary
Public methods |
|
---|---|
operator T |
The componentN() operators allow state objects to be used with the property destructuring syntax |
operator (T) -> Unit | |
operator T |
The getValue/setValue operators allow State to be used as a local variable with a delegate: |
Unit |
prependFrameRecord(value: Record) Add a new state record to the beginning of a list. |
operator Unit |
Properties |
|
---|---|
Record |
The first state record in a linked list of state records. |
T |
the wrapped value |
Public methods
component1
operator fun component1(): T
The componentN() operators allow state objects to be used with the property destructuring syntax
var (foo, setFoo) = +state { 0 } setFoo(123) // set foo == 123 // get
component2
operator fun component2(): (T) -> Unit
getValue
operator fun getValue(
thisObj: Any?,
property: KProperty<*>
): T
The getValue/setValue operators allow State to be used as a local variable with a delegate:
var foo by +state { 0 } foo += 123 // uses setValue(...) foo == 123 // uses getValue(...)
prependFrameRecord
fun prependFrameRecord(value: Record): Unit
Add a new state record to the beginning of a list. After this call firstFrameRecord should be value.
Properties
firstFrameRecord
val firstFrameRecord: Record
The first state record in a linked list of state records.