# androidx.compose.runtime.snapshots

Common/AllAndroid/JVMNative/C/iOSJavaScript

## Interfaces

|---|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/ObserverHandle` | The type returned by observer registration methods that unregisters the observer when it is disposed. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/SnapshotContextElement` | A `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.coroutines/-coroutine-context/index.html` element that `https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/Snapshot#enter(kotlin.Function0)` an associated snapshot whenever a coroutine associated with this context is resumed. | Cmn |
| `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. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/StateObject` | Interface implemented by all snapshot aware state objects. | Cmn |

## Classes

|---|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/MutableSnapshot` | A snapshot of the values return by mutable states and other state objects. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/Snapshot` | A snapshot of the values return by mutable states and other state objects. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/SnapshotApplyResult` | The result of a applying a mutable snapshot. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/SnapshotApplyResult.Failure` |   | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/SnapshotId` | The type of `https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/Snapshot#snapshotId()`. | Cmn android N JS |
| `https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/SnapshotIdArray` | An array of `https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/SnapshotId`. | Cmn android N JS |
| `https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/SnapshotStateList` | An implementation of `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-list/index.html` that can be observed and snapshot. | Cmn android |
| `https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/SnapshotStateMap` | An implementation of `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-map/index.html` that can be observed and snapshot. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/SnapshotStateObserver` | Helper class to efficiently observe snapshot state reads. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/SnapshotStateSet` | An implementation of `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-set/index.html` that can be observed and snapshot. | Cmn android |
| `https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/StateRecord` | Snapshot local value of a state object. | Cmn |

## Exceptions

|---|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/SnapshotApplyConflictException` | An exception that is thrown when `https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/SnapshotApplyResult#check()` is called on a result of a `https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/MutableSnapshot#apply()` that fails to apply. | Cmn |

## Objects

|---|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/Snapshot.Companion` |   | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/SnapshotApplyResult.Success` |   | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/SnapshotContextElement.Key` |   | Cmn |

## Annotations

|---|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/AutoboxingStateValueProperty` | This annotation designates that a property on a `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-state/index.html` class will autobox when it is read from or assigned to. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/StateFactoryMarker` | Designates a function as a factory function that produces a State object. | Cmn |

## Type aliases

|---|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/SnapshotId` | The type of `https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/Snapshot#snapshotId()`. | android N JS |
| `https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/SnapshotIdArray` | An array of `https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/SnapshotId`. | android N JS |

## Top-level functions summary

|---|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/SnapshotStateList<T>` | `<T : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?> https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/package-summary#SnapshotStateList(kotlin.Int,kotlin.Function1)(size: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, init: (index: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) -> T)` Creates a new snapshot state list with the specified `https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/package-summary#SnapshotStateList(kotlin.Int,kotlin.Function1)`, where each element is calculated by calling the specified `https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/package-summary#SnapshotStateList(kotlin.Int,kotlin.Function1)` function. | Cmn |

## Extension functions summary

|---|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/SnapshotContextElement` | `https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/Snapshot.https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/package-summary#(androidx.compose.runtime.snapshots.Snapshot).asContextElement()()` Return a `https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/SnapshotContextElement` that will `https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/Snapshot#enter(kotlin.Function0)` this `https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/Snapshot` whenever the associated coroutine is resumed and leave this snapshot when it suspends. | Cmn |
| `T` | `<T : https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/StateRecord> T.https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/package-summary#(androidx.compose.runtime.snapshots.StateRecord).readable(androidx.compose.runtime.snapshots.StateObject)(state: https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/StateObject)` Return the current readable state record for the current snapshot. | Cmn |
| `T` | `<T : https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/StateRecord> T.https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/package-summary#(androidx.compose.runtime.snapshots.StateRecord).readable(androidx.compose.runtime.snapshots.StateObject,androidx.compose.runtime.snapshots.Snapshot)(state: https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/StateObject, snapshot: https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/Snapshot)` Return the current readable state record for the `https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/package-summary#(androidx.compose.runtime.snapshots.StateRecord).readable(androidx.compose.runtime.snapshots.StateObject,androidx.compose.runtime.snapshots.Snapshot)`. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/SnapshotId.https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/package-summary#(androidx.compose.runtime.snapshots.SnapshotId).toInt()()` | Cmn |
| `inline https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-double/index.html.https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/package-summary#(kotlin.Double).toInt()()` | JS |
| `inline https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html.https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/package-summary#(kotlin.Long).toInt()()` | android N JS |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/SnapshotId.https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/package-summary#(androidx.compose.runtime.snapshots.SnapshotId).toLong()()` | Cmn |
| `inline https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-double/index.html.https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/package-summary#(kotlin.Double).toLong()()` | JS |
| `inline https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html.https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/package-summary#(kotlin.Long).toLong()()` | android N JS |
| `inline R` | `<T : https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/StateRecord, R : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?> T.[withCurrent](https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/package-summary#(androidx.compose.runtime.snapshots.StateRecord).withCurrent(kotlin.Function1))(block: (r) -> R)` **This function is deprecated.** Use the overload that has a StateObject parameter instead; for example, next.withCurrent(this) { ... } | Cmn |
| `inline R` | `<T : https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/StateRecord, R : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?> T.https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/package-summary#(androidx.compose.runtime.snapshots.StateRecord).withCurrent(androidx.compose.runtime.snapshots.StateObject,kotlin.Function1)(state: https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/StateObject, block: (r) -> R)` Provides a `https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/package-summary#(androidx.compose.runtime.snapshots.StateRecord).withCurrent(androidx.compose.runtime.snapshots.StateObject,kotlin.Function1)` with the current record, without notifying any read observers. | Cmn |
| `inline R` | `<T : https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/StateRecord, R : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?> T.https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/package-summary#(androidx.compose.runtime.snapshots.StateRecord).writable(androidx.compose.runtime.snapshots.StateObject,kotlin.Function1)(state: https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/StateObject, block: T.() -> R)` Call `https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/package-summary#(androidx.compose.runtime.snapshots.StateRecord).writable(androidx.compose.runtime.snapshots.StateObject,kotlin.Function1)` with a writable state record for the given record. | Cmn |
| `inline R` | `<T : https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/StateRecord, R : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?> T.https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/package-summary#(androidx.compose.runtime.snapshots.StateRecord).writable(androidx.compose.runtime.snapshots.StateObject,androidx.compose.runtime.snapshots.Snapshot,kotlin.Function1)( state: https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/StateObject, snapshot: https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/Snapshot, block: T.() -> R )` Call `https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/package-summary#(androidx.compose.runtime.snapshots.StateRecord).writable(androidx.compose.runtime.snapshots.StateObject,androidx.compose.runtime.snapshots.Snapshot,kotlin.Function1)` with a writable state record for `https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/package-summary#(androidx.compose.runtime.snapshots.StateRecord).writable(androidx.compose.runtime.snapshots.StateObject,androidx.compose.runtime.snapshots.Snapshot,kotlin.Function1)` of the given record. | Cmn |

## Top-level functions

### SnapshotStateList

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/snapshots/SnapshotStateList.kt+function:SnapshotStateList) Added in [1.8.0](https://developer.android.com/jetpack/androidx/releases/compose-runtime#1.8.0)

```
fun <T : Any?> SnapshotStateList(size: Int, init: (index: Int) -> T): SnapshotStateList<T>
```

Creates a new snapshot state list with the specified `https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/package-summary#SnapshotStateList(kotlin.Int,kotlin.Function1)`, where each element is calculated by calling the specified `https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/package-summary#SnapshotStateList(kotlin.Int,kotlin.Function1)` function.

The function `https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/package-summary#SnapshotStateList(kotlin.Int,kotlin.Function1)` is called for each list element sequentially starting from the first one. It should return the value for a list element given its index.

## Extension functions

### Snapshot.asContextElement

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/snapshots/SnapshotContextElement.kt+function:asContextElement) Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/compose-runtime#1.2.0)

```
fun Snapshot.asContextElement(): SnapshotContextElement
```

Return a `https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/SnapshotContextElement` that will `https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/Snapshot#enter(kotlin.Function0)` this `https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/Snapshot` whenever the associated coroutine is resumed and leave this snapshot when it suspends. The snapshot still must be `https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/Snapshot#dispose()` separately when it will no longer be used.

```kotlin
import androidx.compose.runtime.snapshots.Snapshot
import androidx.compose.runtime.snapshots.asContextElement

runBlocking {
    val snapshot = Snapshot.takeSnapshot()
    try {
        withContext(snapshot.asContextElement()) {
            // Data observed by separately reading stateA and stateB are consistent with
            // the snapshot context element across suspensions
            doSomethingSuspending(someObject.stateA)
            doSomethingSuspending(someObject.stateB)
        }
    } finally {
        // Snapshot must be disposed after it will not be used again
        snapshot.dispose()
    }
}
```

### T.readable

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/snapshots/Snapshot.kt+function:readable) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-runtime#1.0.0)

```
fun <T : StateRecord> T.readable(state: StateObject): T
```

Return the current readable state record for the current snapshot. It is assumed that `https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/package-summary#(androidx.compose.runtime.snapshots.StateRecord).readable(androidx.compose.runtime.snapshots.StateObject)` is the first record of `https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/package-summary#(androidx.compose.runtime.snapshots.StateRecord).readable(androidx.compose.runtime.snapshots.StateObject)`

### T.readable

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/snapshots/Snapshot.kt+function:readable) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-runtime#1.0.0)

```
fun <T : StateRecord> T.readable(state: StateObject, snapshot: Snapshot): T
```

Return the current readable state record for the `https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/package-summary#(androidx.compose.runtime.snapshots.StateRecord).readable(androidx.compose.runtime.snapshots.StateObject,androidx.compose.runtime.snapshots.Snapshot)`. It is assumed that `https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/package-summary#(androidx.compose.runtime.snapshots.StateRecord).readable(androidx.compose.runtime.snapshots.StateObject,androidx.compose.runtime.snapshots.Snapshot)` is the first record of `https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/package-summary#(androidx.compose.runtime.snapshots.StateRecord).readable(androidx.compose.runtime.snapshots.StateObject,androidx.compose.runtime.snapshots.Snapshot)`

### SnapshotId.toInt

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/snapshots/SnapshotId.kt+function:toInt)

```
fun SnapshotId.toInt(): Int
```

### Double.toInt

JS 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/snapshots/SnapshotId.js.kt+function:toInt)

```
inline fun Double.toInt(): Int
```

### Long.toInt

android N JS [View Source](https://cs.android.com/search?q=file:androidx/compose/runtime/snapshots/SnapshotId.+function:toInt) Added in 1.8.0

```
inline fun Long.toInt(): Int
```

### SnapshotId.toLong

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/snapshots/SnapshotId.kt+function:toLong)

```
fun SnapshotId.toLong(): Long
```

### Double.toLong

JS 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/snapshots/SnapshotId.js.kt+function:toLong)

```
inline fun Double.toLong(): Long
```

### Long.toLong

android N JS [View Source](https://cs.android.com/search?q=file:androidx/compose/runtime/snapshots/SnapshotId.+function:toLong) Added in 1.8.0

```
inline fun Long.toLong(): Long
```

### T.withCurrent

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/snapshots/Snapshot.kt+function:withCurrent) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-runtime#1.0.0) Deprecated in [1.13.0-rc01](https://developer.android.com/jetpack/androidx/releases/compose-runtime#1.13.0-rc01)

```
inline fun <T : StateRecord, R : Any?> T.[withCurrent](https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/package-summary#(androidx.compose.runtime.snapshots.StateRecord).withCurrent(kotlin.Function1))(block: (r) -> R): R
```

> [!CAUTION]
> **This function is deprecated.**   
> Use the overload that has a StateObject parameter instead; for example, next.withCurrent(this) { ... }

Provides a `https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/package-summary#(androidx.compose.runtime.snapshots.StateRecord).withCurrent(kotlin.Function1)` with the current record, without notifying any read observers.

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/package-summary#readable(androidx.compose.runtime.snapshots.StateRecord,androidx.compose.runtime.snapshots.SnapshotId,androidx.compose.runtime.snapshots.SnapshotIdSet)` |   |

### T.withCurrent

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/snapshots/Snapshot.kt+function:withCurrent) Added in [1.13.0-rc01](https://developer.android.com/jetpack/androidx/releases/compose-runtime#1.13.0-rc01)

```
inline fun <T : StateRecord, R : Any?> T.withCurrent(state: StateObject, block: (r) -> R): R
```

Provides a `https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/package-summary#(androidx.compose.runtime.snapshots.StateRecord).withCurrent(androidx.compose.runtime.snapshots.StateObject,kotlin.Function1)` with the current record, without notifying any read observers.

| Parameters |
|---|---|
| `state: https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/StateObject` | the state object for which the receiver is a state record. It is assumed that `https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/package-summary#(androidx.compose.runtime.snapshots.StateRecord).withCurrent(androidx.compose.runtime.snapshots.StateObject,kotlin.Function1)` is the first record of `https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/package-summary#(androidx.compose.runtime.snapshots.StateRecord).withCurrent(androidx.compose.runtime.snapshots.StateObject,kotlin.Function1)` (e.g. `next.withCurrent(this) { ... }`). |
| `block: (r) -> R` | a block to be evaluated with the current state record as its parameter. The result of `https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/package-summary#(androidx.compose.runtime.snapshots.StateRecord).withCurrent(androidx.compose.runtime.snapshots.StateObject,kotlin.Function1)` is the result of `https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/package-summary#(androidx.compose.runtime.snapshots.StateRecord).withCurrent(androidx.compose.runtime.snapshots.StateObject,kotlin.Function1)`. It is expected, but not required, that the result of block is either `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` or derives it value from the content of the state record. |

| Returns |
|---|---|
| `R` | the result returned by the `https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/package-summary#(androidx.compose.runtime.snapshots.StateRecord).withCurrent(androidx.compose.runtime.snapshots.StateObject,kotlin.Function1)` lambda. |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/package-summary#readable(androidx.compose.runtime.snapshots.StateRecord,androidx.compose.runtime.snapshots.SnapshotId,androidx.compose.runtime.snapshots.SnapshotIdSet)` |   |

### T.writable

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/snapshots/Snapshot.kt+function:writable) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-runtime#1.0.0)

```
inline fun <T : StateRecord, R : Any?> T.writable(state: StateObject, block: T.() -> R): R
```

Call `https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/package-summary#(androidx.compose.runtime.snapshots.StateRecord).writable(androidx.compose.runtime.snapshots.StateObject,kotlin.Function1)` with a writable state record for the given record. It is assumed that this is called for the first state record in a state object. A record is writable if it was created in the current mutable snapshot.

### T.writable

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/snapshots/Snapshot.kt+function:writable) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-runtime#1.0.0)

```
inline fun <T : StateRecord, R : Any?> T.writable(
    state: StateObject,
    snapshot: Snapshot,
    block: T.() -> R
): R
```

Call `https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/package-summary#(androidx.compose.runtime.snapshots.StateRecord).writable(androidx.compose.runtime.snapshots.StateObject,androidx.compose.runtime.snapshots.Snapshot,kotlin.Function1)` with a writable state record for `https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/package-summary#(androidx.compose.runtime.snapshots.StateRecord).writable(androidx.compose.runtime.snapshots.StateObject,androidx.compose.runtime.snapshots.Snapshot,kotlin.Function1)` of the given record. It is assumed that this is called for the first state record in a state object. If the snapshot is read-only calling this will throw.