# State

Artifact: [androidx.compose.runtime:runtime](https://developer.android.com/jetpack/androidx/releases/compose-runtime) [View Source](https://cs.android.com/search?q=file:androidx/compose/runtime/SnapshotState.kt+class:androidx.compose.runtime.State) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-runtime#1.0.0) Common/AllAndroid/JVMNative/C/iOSJavaScript
- Cmn

  ```
  interface State<T : Any?>
  ```
Known direct subclasses [AnimationState](https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationState), [DisposableState](https://developer.android.com/reference/kotlin/androidx/appstate/transform/DisposableState), [DoubleState](https://developer.android.com/reference/kotlin/androidx/compose/runtime/DoubleState), [FloatState](https://developer.android.com/reference/kotlin/androidx/compose/runtime/FloatState), [InfiniteTransition.TransitionAnimationState](https://developer.android.com/reference/kotlin/androidx/compose/animation/core/InfiniteTransition.TransitionAnimationState), [IntState](https://developer.android.com/reference/kotlin/androidx/compose/runtime/IntState), [LongState](https://developer.android.com/reference/kotlin/androidx/compose/runtime/LongState), [MutableState](https://developer.android.com/reference/kotlin/androidx/compose/runtime/MutableState), [ToolingState](https://developer.android.com/reference/kotlin/androidx/compose/ui/tooling/animation/ToolingState), [Transition.TransitionAnimationState](https://developer.android.com/reference/kotlin/androidx/compose/animation/core/Transition.TransitionAnimationState)

|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationState` | `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationState` contains the necessary information to indicate the state of an animation. |
| `https://developer.android.com/reference/kotlin/androidx/appstate/transform/DisposableState` | A `https://developer.android.com/reference/kotlin/androidx/compose/runtime/State` that can be disposed to stop its underlying state transformation. |
| `https://developer.android.com/reference/kotlin/androidx/compose/runtime/DoubleState` | A value holder where reads to the `https://developer.android.com/reference/kotlin/androidx/compose/runtime/DoubleState#doubleValue()` property during the execution of a `https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composable` function cause the current `https://developer.android.com/reference/kotlin/androidx/compose/runtime/RecomposeScope` to subscribe to changes of that value. |
| `https://developer.android.com/reference/kotlin/androidx/compose/runtime/FloatState` | A value holder where reads to the `https://developer.android.com/reference/kotlin/androidx/compose/runtime/FloatState#floatValue()` property during the execution of a `https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composable` function cause the current `https://developer.android.com/reference/kotlin/androidx/compose/runtime/RecomposeScope` to subscribe to changes of that value. |
| `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/InfiniteTransition.TransitionAnimationState` | Each animation created using `https://developer.android.com/reference/kotlin/androidx/compose/animation/animateColor.composable#(androidx.compose.animation.core.Transition).animateColor(kotlin.Function1,kotlin.String,kotlin.Function1)`, `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/animateFloat.composable#(androidx.compose.animation.core.InfiniteTransition).animateFloat(kotlin.Float,kotlin.Float,androidx.compose.animation.core.InfiniteRepeatableSpec,kotlin.String)`, or `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/animateValue.composable#(androidx.compose.animation.core.InfiniteTransition).animateValue(kotlin.Any,kotlin.Any,androidx.compose.animation.core.TwoWayConverter,androidx.compose.animation.core.InfiniteRepeatableSpec,kotlin.String)` is represented as a `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/InfiniteTransition.TransitionAnimationState` in `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/InfiniteTransition`. |
| `https://developer.android.com/reference/kotlin/androidx/compose/runtime/IntState` | A value holder where reads to the `https://developer.android.com/reference/kotlin/androidx/compose/runtime/IntState#intValue()` property during the execution of a `https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composable` function cause the current `https://developer.android.com/reference/kotlin/androidx/compose/runtime/RecomposeScope` to subscribe to changes of that value. |
| `https://developer.android.com/reference/kotlin/androidx/compose/runtime/LongState` | A value holder where reads to the `https://developer.android.com/reference/kotlin/androidx/compose/runtime/LongState#longValue()` property during the execution of a `https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composable` function cause the current `https://developer.android.com/reference/kotlin/androidx/compose/runtime/RecomposeScope` to subscribe to changes of that value. |
| `https://developer.android.com/reference/kotlin/androidx/compose/runtime/MutableState` | A mutable value holder where reads to the `https://developer.android.com/reference/kotlin/androidx/compose/runtime/MutableState#value()` property during the execution of a `https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composable` function, the current `https://developer.android.com/reference/kotlin/androidx/compose/runtime/RecomposeScope` will be subscribed to changes of that value. |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/tooling/animation/ToolingState` | Tooling can override `https://developer.android.com/reference/kotlin/androidx/compose/runtime/package-summary#mutableStateOf(kotlin.Any,androidx.compose.runtime.SnapshotMutationPolicy)` in `https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composable` with `https://developer.android.com/reference/kotlin/androidx/compose/ui/tooling/animation/ToolingState`. |
| `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/Transition.TransitionAnimationState` | Each animation created using `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/animateFloat.composable#(androidx.compose.animation.core.InfiniteTransition).animateFloat(kotlin.Float,kotlin.Float,androidx.compose.animation.core.InfiniteRepeatableSpec,kotlin.String)`, `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/animateDp.composable#(androidx.compose.animation.core.Transition).animateDp(kotlin.Function1,kotlin.String,kotlin.Function1)`, etc is represented as a `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/Transition.TransitionAnimationState` in `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/Transition`. |

Known indirect subclasses [MutableDoubleState](https://developer.android.com/reference/kotlin/androidx/compose/runtime/MutableDoubleState), [MutableFloatState](https://developer.android.com/reference/kotlin/androidx/compose/runtime/MutableFloatState), [MutableIntState](https://developer.android.com/reference/kotlin/androidx/compose/runtime/MutableIntState), [MutableLongState](https://developer.android.com/reference/kotlin/androidx/compose/runtime/MutableLongState), [ProduceStateScope](https://developer.android.com/reference/kotlin/androidx/compose/runtime/ProduceStateScope), [SnapshotMutableState](https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/SnapshotMutableState)

|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/runtime/MutableDoubleState` | A value holder where reads to the `https://developer.android.com/reference/kotlin/androidx/compose/runtime/MutableDoubleState#doubleValue()` property during the execution of a `https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composable` function cause the current `https://developer.android.com/reference/kotlin/androidx/compose/runtime/RecomposeScope` to subscribe to changes of that value. |
| `https://developer.android.com/reference/kotlin/androidx/compose/runtime/MutableFloatState` | A value holder where reads to the `https://developer.android.com/reference/kotlin/androidx/compose/runtime/MutableFloatState#floatValue()` property during the execution of a `https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composable` function cause the current `https://developer.android.com/reference/kotlin/androidx/compose/runtime/RecomposeScope` to subscribe to changes of that value. |
| `https://developer.android.com/reference/kotlin/androidx/compose/runtime/MutableIntState` | A value holder where reads to the `https://developer.android.com/reference/kotlin/androidx/compose/runtime/MutableIntState#intValue()` property during the execution of a `https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composable` function cause the current `https://developer.android.com/reference/kotlin/androidx/compose/runtime/RecomposeScope` to subscribe to changes of that value. |
| `https://developer.android.com/reference/kotlin/androidx/compose/runtime/MutableLongState` | A value holder where reads to the `https://developer.android.com/reference/kotlin/androidx/compose/runtime/MutableLongState#longValue()` property during the execution of a `https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composable` function cause the current `https://developer.android.com/reference/kotlin/androidx/compose/runtime/RecomposeScope` to subscribe to changes of that value. |
| `https://developer.android.com/reference/kotlin/androidx/compose/runtime/ProduceStateScope` | Receiver scope for use with `https://developer.android.com/reference/kotlin/androidx/compose/runtime/produceState.composable#produceState(kotlin.Any,kotlin.coroutines.SuspendFunction1)`. |
| `https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/SnapshotMutableState` | A mutable value holder where reads to the `https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/SnapshotMutableState#value()` property during the execution of a `https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composable` function, the current `https://developer.android.com/reference/kotlin/androidx/compose/runtime/RecomposeScope` will be subscribed to changes of that value. |

*** ** * ** ***

A value holder where reads to the `https://developer.android.com/reference/kotlin/androidx/compose/runtime/State#value()` property during the execution of a `https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composable` function, the current `https://developer.android.com/reference/kotlin/androidx/compose/runtime/RecomposeScope` will be subscribed to changes of that value.

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/runtime/MutableState` |   |
| `https://developer.android.com/reference/kotlin/androidx/compose/runtime/package-summary#mutableStateOf(kotlin.Any,androidx.compose.runtime.SnapshotMutationPolicy)` |   |

## Summary

| ### Public properties |
|---|---|---|
| `T` | `https://developer.android.com/reference/kotlin/androidx/compose/runtime/State#value()` | Cmn |

| ### Extension functions |
|---|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/runtime/DoubleState` | `https://developer.android.com/reference/kotlin/androidx/compose/runtime/State<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-double/index.html>.https://developer.android.com/reference/kotlin/androidx/compose/runtime/State#(androidx.compose.runtime.State).asDoubleState()()` Converts a `State<Double>` (as in, a `https://developer.android.com/reference/kotlin/androidx/compose/runtime/State` of boxed `Double`s) into a primitive-backed `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-double/index.html`. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/runtime/FloatState` | `https://developer.android.com/reference/kotlin/androidx/compose/runtime/State<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html>.https://developer.android.com/reference/kotlin/androidx/compose/runtime/State#(androidx.compose.runtime.State).asFloatState()()` Converts a `State<Float>` (as in, a `https://developer.android.com/reference/kotlin/androidx/compose/runtime/State` of boxed `Float`s) into a primitive-backed `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html`. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/runtime/IntState` | `https://developer.android.com/reference/kotlin/androidx/compose/runtime/State<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html>.https://developer.android.com/reference/kotlin/androidx/compose/runtime/State#(androidx.compose.runtime.State).asIntState()()` Converts a `State<Int>` (as in, a `https://developer.android.com/reference/kotlin/androidx/compose/runtime/State` of boxed `Int`s) into a primitive-backed `https://developer.android.com/reference/kotlin/androidx/compose/runtime/IntState`. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/runtime/LongState` | `https://developer.android.com/reference/kotlin/androidx/compose/runtime/State<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html>.https://developer.android.com/reference/kotlin/androidx/compose/runtime/State#(androidx.compose.runtime.State).asLongState()()` Converts a `State<Long>` (as in, a `https://developer.android.com/reference/kotlin/androidx/compose/runtime/State` of boxed `Long`s) into a primitive-backed `https://developer.android.com/reference/kotlin/androidx/compose/runtime/LongState`. | Cmn |
| `inline operator T` | `<T : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?> https://developer.android.com/reference/kotlin/androidx/compose/runtime/State<T>.https://developer.android.com/reference/kotlin/androidx/compose/runtime/State#(androidx.compose.runtime.State).getValue(kotlin.Any,kotlin.reflect.KProperty)(thisObj: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?, property: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.reflect/-k-property/index.html<*>)` Permits property delegation of `val`s using `by` for `https://developer.android.com/reference/kotlin/androidx/compose/runtime/State`. | Cmn |

## Public properties

### value

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-runtime#1.0.0)

```
val value: T
```

## Extension functions

### State.asDoubleState

Cmn Artifact: [androidx.compose.runtime:runtime](https://developer.android.com/jetpack/androidx/releases/compose-runtime) [View Source](https://cs.android.com/search?q=file:androidx/compose/runtime/SnapshotStateExtensions.kt+function:asDoubleState)

```
fun State<Double>.asDoubleState(): DoubleState
```

Converts a `State<Double>` (as in, a `https://developer.android.com/reference/kotlin/androidx/compose/runtime/State` of boxed `Double`s) into a primitive-backed `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-double/index.html`. 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 `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-double/index.html` attempts to escape, but instead is intended to allow interoperability between components that use either representation of a state of type `Double`.

### State.asFloatState

Cmn Artifact: [androidx.compose.runtime:runtime](https://developer.android.com/jetpack/androidx/releases/compose-runtime) [View Source](https://cs.android.com/search?q=file:androidx/compose/runtime/SnapshotStateExtensions.kt+function:asFloatState)

```
fun State<Float>.asFloatState(): FloatState
```

Converts a `State<Float>` (as in, a `https://developer.android.com/reference/kotlin/androidx/compose/runtime/State` of boxed `Float`s) into a primitive-backed `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html`. 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 `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` attempts to escape, but instead is intended to allow interoperability between components that use either representation of a state of type `Float`.

### State.asIntState

Cmn Artifact: [androidx.compose.runtime:runtime](https://developer.android.com/jetpack/androidx/releases/compose-runtime) [View Source](https://cs.android.com/search?q=file:androidx/compose/runtime/SnapshotStateExtensions.kt+function:asIntState)

```
fun State<Int>.asIntState(): IntState
```

Converts a `State<Int>` (as in, a `https://developer.android.com/reference/kotlin/androidx/compose/runtime/State` of boxed `Int`s) into a primitive-backed `https://developer.android.com/reference/kotlin/androidx/compose/runtime/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 `https://developer.android.com/reference/kotlin/androidx/compose/runtime/IntState` attempts to escape, but instead is intended to allow interoperability between components that use either representation of a state of type `Int`.

### State.asLongState

Cmn Artifact: [androidx.compose.runtime:runtime](https://developer.android.com/jetpack/androidx/releases/compose-runtime) [View Source](https://cs.android.com/search?q=file:androidx/compose/runtime/SnapshotStateExtensions.kt+function:asLongState)

```
fun State<Long>.asLongState(): LongState
```

Converts a `State<Long>` (as in, a `https://developer.android.com/reference/kotlin/androidx/compose/runtime/State` of boxed `Long`s) into a primitive-backed `https://developer.android.com/reference/kotlin/androidx/compose/runtime/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 `https://developer.android.com/reference/kotlin/androidx/compose/runtime/LongState` attempts to escape, but instead is intended to allow interoperability between components that use either representation of a state of type `Long`.

### State.getValue

Cmn Artifact: [androidx.compose.runtime:runtime](https://developer.android.com/jetpack/androidx/releases/compose-runtime) [View Source](https://cs.android.com/search?q=file:androidx/compose/runtime/SnapshotState.kt+function:getValue)

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

Permits property delegation of `val`s using `by` for `https://developer.android.com/reference/kotlin/androidx/compose/runtime/State`.

```kotlin
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")
}
```