# retainManagedRetainedValuesStore

Common/All

## Functions summary

|---|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/runtime/retain/ManagedRetainedValuesStore` | `@https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composable https://developer.android.com/reference/kotlin/androidx/compose/runtime/retain/retainManagedRetainedValuesStore.composable#retainManagedRetainedValuesStore()()` Retains a `https://developer.android.com/reference/kotlin/androidx/compose/runtime/retain/ManagedRetainedValuesStore`. | Cmn |

## Functions

### retainManagedRetainedValuesStore

Cmn Artifact: [androidx.compose.runtime:runtime-retain](https://developer.android.com/jetpack/androidx/releases/compose-runtime) [View Source](https://cs.android.com/search?q=file:androidx/compose/runtime/retain/ManagedRetainedValuesStore.kt+function:retainManagedRetainedValuesStore) Added in [1.10.0](https://developer.android.com/jetpack/androidx/releases/compose-runtime#1.10.0)

```
@Composable
fun retainManagedRetainedValuesStore(): ManagedRetainedValuesStore
```

Retains a `https://developer.android.com/reference/kotlin/androidx/compose/runtime/retain/ManagedRetainedValuesStore`. The returned store follows the lifespan defined by `https://developer.android.com/reference/kotlin/androidx/compose/runtime/retain/retain.composable#retain(kotlin.Function0)`. When the retained scope is retired, it will be `https://developer.android.com/reference/kotlin/androidx/compose/runtime/retain/ManagedRetainedValuesStore#dispose()`.

Optionally, you can enable and disable retention of exited values on this scope via `https://developer.android.com/reference/kotlin/androidx/compose/runtime/retain/ManagedRetainedValuesStore#enableRetainingExitedValues()` and `https://developer.android.com/reference/kotlin/androidx/compose/runtime/retain/ManagedRetainedValuesStore#disableRetainingExitedValues()`. (The scope is enabled by default.)

```kotlin
import androidx.compose.animation.AnimatedContent
import androidx.compose.runtime.Composable
import androidx.compose.runtime.retain.LocalRetainedValuesStoreProvider
import androidx.compose.runtime.retain.retain
import androidx.compose.runtime.retain.retainManagedRetainedValuesStore

@Composable
fun RetainedAnimatedContent(active: Boolean, content: @Composable () -> Unit) {
    // Create a RetainedValuesStore. It will be added as a child to the current store and start
    // retaining exited values when the parent does. On Android, this store will implicitly
    // survive and forward retention events caused by configuration changes.
    val retainedValuesStore = retainManagedRetainedValuesStore()
    AnimatedContent(active) { targetState ->
        if (targetState) {
            // Install the RetainedValuesStore over the child content
            LocalRetainedValuesStoreProvider(retainedValuesStore) {
                // Values retained here will be kept when this content is faded out,
                // and restored when the content is added back to the composition.
                content()
            }
        }
    }
}
```

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/runtime/retain/ManagedRetainedValuesStore` | A `https://developer.android.com/reference/kotlin/androidx/compose/runtime/retain/ManagedRetainedValuesStore` nested under the `https://developer.android.com/reference/kotlin/androidx/compose/runtime/retain/package-summary#LocalRetainedValuesStore()`, ready to be installed with `https://developer.android.com/reference/kotlin/androidx/compose/runtime/retain/LocalRetainedValuesStoreProvider.composable#LocalRetainedValuesStoreProvider(androidx.compose.runtime.retain.RetainedValuesStore,kotlin.Function0)`. |