The Android Developer Challenge is back! Submit your idea before December 2.

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
getValue(thisObj: Any?, property: KProperty<*>)

The getValue/setValue operators allow State to be used as a local variable with a delegate:

Unit

operator Unit
setValue(thisObj: Any?, property: KProperty<*>, next: T)

Properties

Record

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

setValue

operator fun setValue(
    thisObj: Any?,
    property: KProperty<*>,
    next: T
): Unit

Properties

firstFrameRecord

val firstFrameRecord: Record

value

var value: T

the wrapped value

See Also