# RetainedEffectScope

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/RetainedEffect.kt+class:androidx.compose.runtime.retain.RetainedEffectScope) Added in [1.10.0](https://developer.android.com/jetpack/androidx/releases/compose-runtime#1.10.0) Common/All
- Cmn

  ```
  class RetainedEffectScope
  ```

*** ** * ** ***

Receiver scope for `https://developer.android.com/reference/kotlin/androidx/compose/runtime/retain/RetainedEffect.composable#RetainedEffect(kotlin.Function1)` that offers the `https://developer.android.com/reference/kotlin/androidx/compose/runtime/retain/RetainedEffectScope#onRetire(kotlin.Function0)` clause that should be the last statement in any call to `https://developer.android.com/reference/kotlin/androidx/compose/runtime/retain/RetainedEffect.composable#RetainedEffect(kotlin.Function1)`.

## Summary

| ### Public constructors |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/runtime/retain/RetainedEffectScope#RetainedEffectScope()()` | Cmn |

| ### Public functions |
|---|---|---|
| `inline https://developer.android.com/reference/kotlin/androidx/compose/runtime/retain/RetainedEffectResult` | `https://developer.android.com/reference/kotlin/androidx/compose/runtime/retain/RetainedEffectScope#onRetire(kotlin.Function0)(crossinline onRetiredEffect: () -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)` Provide `https://developer.android.com/reference/kotlin/androidx/compose/runtime/retain/RetainedEffectScope#onRetire(kotlin.Function0)` to the `https://developer.android.com/reference/kotlin/androidx/compose/runtime/retain/RetainedEffect.composable#RetainedEffect(kotlin.Function1)` to run when it leaves the composition or its key changes. | Cmn |

## Public constructors

### RetainedEffectScope

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

```
RetainedEffectScope()
```

## Public functions

### onRetire

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

```
inline fun onRetire(crossinline onRetiredEffect: () -> Unit): RetainedEffectResult
```

Provide `https://developer.android.com/reference/kotlin/androidx/compose/runtime/retain/RetainedEffectScope#onRetire(kotlin.Function0)` to the `https://developer.android.com/reference/kotlin/androidx/compose/runtime/retain/RetainedEffect.composable#RetainedEffect(kotlin.Function1)` to run when it leaves the composition or its key changes.