# LocalRetainedValuesStoreProvider

Common/All

## Functions summary

|---|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composable https://developer.android.com/reference/kotlin/androidx/compose/runtime/retain/LocalRetainedValuesStoreProvider.composable#LocalRetainedValuesStoreProvider(androidx.compose.runtime.retain.RetainedValuesStore,kotlin.Function0)( store: https://developer.android.com/reference/kotlin/androidx/compose/runtime/retain/RetainedValuesStore, content: @https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composable () -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html )` Installs the given `https://developer.android.com/reference/kotlin/androidx/compose/runtime/retain/RetainedValuesStore` over the provided `https://developer.android.com/reference/kotlin/androidx/compose/runtime/retain/package-summary#LocalRetainedValuesStoreProvider(androidx.compose.runtime.retain.RetainedValuesStore,kotlin.Function0)` such that all values retained in the `https://developer.android.com/reference/kotlin/androidx/compose/runtime/retain/package-summary#LocalRetainedValuesStoreProvider(androidx.compose.runtime.retain.RetainedValuesStore,kotlin.Function0)` lambda are owned by `https://developer.android.com/reference/kotlin/androidx/compose/runtime/retain/package-summary#LocalRetainedValuesStoreProvider(androidx.compose.runtime.retain.RetainedValuesStore,kotlin.Function0)`. | Cmn |

## Functions

### LocalRetainedValuesStoreProvider

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

```
@Composable
fun LocalRetainedValuesStoreProvider(
    store: RetainedValuesStore,
    content: @Composable () -> Unit
): Unit
```

Installs the given `https://developer.android.com/reference/kotlin/androidx/compose/runtime/retain/RetainedValuesStore` over the provided `https://developer.android.com/reference/kotlin/androidx/compose/runtime/retain/package-summary#LocalRetainedValuesStoreProvider(androidx.compose.runtime.retain.RetainedValuesStore,kotlin.Function0)` such that all values retained in the `https://developer.android.com/reference/kotlin/androidx/compose/runtime/retain/package-summary#LocalRetainedValuesStoreProvider(androidx.compose.runtime.retain.RetainedValuesStore,kotlin.Function0)` lambda are owned by `https://developer.android.com/reference/kotlin/androidx/compose/runtime/retain/package-summary#LocalRetainedValuesStoreProvider(androidx.compose.runtime.retain.RetainedValuesStore,kotlin.Function0)`. When this provider is removed from composition (and the content is therefore removed with it), the store will be notified to start retaining exited values so that it can persist all retained values at the time the content exits composition.

Note that most `https://developer.android.com/reference/kotlin/androidx/compose/runtime/retain/RetainedValuesStore` implementations can only be provided in one location and composition at a time. Attempting to install the same store twice may lead to an error.

```kotlin
import androidx.compose.runtime.Composable
import androidx.compose.runtime.retain.LocalRetainedValuesStoreProvider
import androidx.compose.runtime.retain.RetainedEffect
import androidx.compose.runtime.retain.retain
import androidx.compose.runtime.retain.retainManagedRetainedValuesStore

@Composable
fun CollapsingMediaPlayer(visible: Boolean) {
    // Important: This retainedValuesStore is created outside of the if statement to ensure
    // that it lives as long as the CollapsingMediaPlayer composable itself.
    val retainedValuesStore = retainManagedRetainedValuesStore()

    // This content is only shown when `visible == true`
    if (visible) {
        LocalRetainedValuesStoreProvider(retainedValuesStore) {
            // Create a media player that will be retained when the CollapsingMediaPlayer is not
            // visible. This component can continue to play audio when the video is hidden.
            val mediaPlayer = retain { MediaPlayer() }
            RetainedEffect(mediaPlayer) {
                mediaPlayer.play()
                onRetire { mediaPlayer.stop() }
            }

            // Render the video component inside the RetainedContentHost.
        }
    }
}
```

| Parameters |
|---|---|
| `store: https://developer.android.com/reference/kotlin/androidx/compose/runtime/retain/RetainedValuesStore` | The `https://developer.android.com/reference/kotlin/androidx/compose/runtime/retain/RetainedValuesStore` to install as the `https://developer.android.com/reference/kotlin/androidx/compose/runtime/retain/package-summary#LocalRetainedValuesStore()` |
| `content: @https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composable () -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | The Composable content that the `https://developer.android.com/reference/kotlin/androidx/compose/runtime/retain/package-summary#LocalRetainedValuesStoreProvider(androidx.compose.runtime.retain.RetainedValuesStore,kotlin.Function0)` will be installed for. This content block is invoked immediately in-place. |