Known direct subclasses
AnimationState

AnimationState contains the necessary information to indicate the state of an animation.

DoubleState

A value holder where reads to the doubleValue property during the execution of a Composable function cause the current RecomposeScope to subscribe to changes of that value.

FloatState

A value holder where reads to the floatValue property during the execution of a Composable function cause the current RecomposeScope to subscribe to changes of that value.

InfiniteTransition.TransitionAnimationState

Each animation created using InfiniteTransition.animateColor, InfiniteTransition.animateFloat, or InfiniteTransition.animateValue is represented as a TransitionAnimationState in InfiniteTransition.

IntState

A value holder where reads to the intValue property during the execution of a Composable function cause the current RecomposeScope to subscribe to changes of that value.

LongState

A value holder where reads to the longValue property during the execution of a Composable function cause the current RecomposeScope to subscribe to changes of that value.

MutableState

A mutable value holder where reads to the value property during the execution of a Composable function, the current RecomposeScope will be subscribed to changes of that value.

ToolingState

Tooling can override mutableStateOf in Composable with ToolingState.

Transition.TransitionAnimationState

Each animation created using animateFloat, animateDp, etc is represented as a TransitionAnimationState in Transition.

Known indirect subclasses
MutableDoubleState

A value holder where reads to the doubleValue property during the execution of a Composable function cause the current RecomposeScope to subscribe to changes of that value.

MutableFloatState

A value holder where reads to the floatValue property during the execution of a Composable function cause the current RecomposeScope to subscribe to changes of that value.

MutableIntState

A value holder where reads to the intValue property during the execution of a Composable function cause the current RecomposeScope to subscribe to changes of that value.

MutableLongState

A value holder where reads to the longValue property during the execution of a Composable function cause the current RecomposeScope to subscribe to changes of that value.

ProduceStateScope

Receiver scope for use with produceState.

SnapshotMutableState

A mutable value holder where reads to the value property during the execution of a Composable function, the current RecomposeScope will be subscribed to changes of that value.


A value holder where reads to the value property during the execution of a Composable function, the current RecomposeScope will be subscribed to changes of that value.

Summary

Public properties

T
Cmn

Extension functions

DoubleState

Converts a State<Double> (as in, a State of boxed Doubles) into a primitive-backed Double.

Cmn
FloatState

Converts a State<Float> (as in, a State of boxed Floats) into a primitive-backed Float.

Cmn
IntState

Converts a State<Int> (as in, a State of boxed Ints) into a primitive-backed IntState.

Cmn
LongState

Converts a State<Long> (as in, a State of boxed Longs) into a primitive-backed LongState.

Cmn
inline operator T
<T : Any?> State<T>.getValue(thisObj: Any?, property: KProperty<*>)

Permits property delegation of vals using by for State.

Cmn

Public properties

value

val value: T

Extension functions

asDoubleState

fun State<Double>.asDoubleState(): DoubleState

Converts a State<Double> (as in, a State of boxed Doubles) into a primitive-backed Double. The state will be automatically unboxed to the required primitive type. The returned state is read-only. The returned state will mirror the values of the base state and apply updates in the same way as the receiver defines.

On the JVM, this conversion does not avoid the autoboxing that Double attempts to escape, but instead is intended to allow interoperability between components that use either representation of a state of type Double.

asFloatState

fun State<Float>.asFloatState(): FloatState

Converts a State<Float> (as in, a State of boxed Floats) into a primitive-backed Float. The state will be automatically unboxed to the required primitive type. The returned state is read-only. The returned state will mirror the values of the base state and apply updates in the same way as the receiver defines.

On the JVM, this conversion does not avoid the autoboxing that Float attempts to escape, but instead is intended to allow interoperability between components that use either representation of a state of type Float.

fun State<Int>.asIntState(): IntState

Converts a State<Int> (as in, a State of boxed Ints) into a primitive-backed IntState. The state will be automatically unboxed to the required primitive type. The returned state is read-only. The returned state will mirror the values of the base state and apply updates in the same way as the receiver defines.

On the JVM, this conversion does not avoid the autoboxing that IntState attempts to escape, but instead is intended to allow interoperability between components that use either representation of a state of type Int.

asLongState

fun State<Long>.asLongState(): LongState

Converts a State<Long> (as in, a State of boxed Longs) into a primitive-backed LongState. The state will be automatically unboxed to the required primitive type. The returned state is read-only. The returned state will mirror the values of the base state and apply updates in the same way as the receiver defines.

On the JVM, this conversion does not avoid the autoboxing that LongState attempts to escape, but instead is intended to allow interoperability between components that use either representation of a state of type Long.

inline operator fun <T : Any?> State<T>.getValue(thisObj: Any?, property: KProperty<*>): T

Permits property delegation of vals using by for State.

import androidx.compose.foundation.layout.Row
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.State

// Composable function that manages a subscription to a data source, returning it as State
@Composable fun observeSampleData(): State<String> = TODO()

// Subscription is managed here, but currentValue is not read yet
val currentValue by observeSampleData()

Row {
    // This scope will recompose when currentValue changes
    Text("Data: $currentValue")
}