# ViewCompositionStrategy.DisposeOnLifecycleDestroyed

Artifact: [androidx.compose.ui:ui](https://developer.android.com/jetpack/androidx/releases/compose-ui) [View Source](https://cs.android.com/search?q=file:androidx/compose/ui/platform/ViewCompositionStrategy.android.kt+class:androidx.compose.ui.platform.ViewCompositionStrategy.DisposeOnLifecycleDestroyed) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0) Common/AllAndroid/JVM
- android

  ```
  class ViewCompositionStrategy.DisposeOnLifecycleDestroyed : ViewCompositionStrategy
  ```

*** ** * ** ***

`https://developer.android.com/reference/kotlin/androidx/compose/ui/platform/ViewCompositionStrategy` that disposes the composition when `https://developer.android.com/reference/kotlin/androidx/compose/ui/platform/ViewCompositionStrategy.DisposeOnLifecycleDestroyed#lifecycle()` is `https://developer.android.com/reference/kotlin/androidx/lifecycle/Lifecycle.Event#ON_DESTROY`. This strategy is appropriate for Compose UI views that share a 1-1 relationship with a known `https://developer.android.com/reference/kotlin/androidx/lifecycle/LifecycleOwner`.

## Summary

| ### Public constructors |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/platform/ViewCompositionStrategy.DisposeOnLifecycleDestroyed#DisposeOnLifecycleDestroyed(androidx.lifecycle.Lifecycle)(lifecycle: https://developer.android.com/reference/kotlin/androidx/lifecycle/Lifecycle)` | android |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/platform/ViewCompositionStrategy.DisposeOnLifecycleDestroyed#DisposeOnLifecycleDestroyed(androidx.lifecycle.LifecycleOwner)(lifecycleOwner: https://developer.android.com/reference/kotlin/androidx/lifecycle/LifecycleOwner)` | android |

| ### Public functions |
|---|---|---|
| `open () -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/platform/ViewCompositionStrategy.DisposeOnLifecycleDestroyed#installFor(androidx.compose.ui.platform.AbstractComposeView)(view: https://developer.android.com/reference/kotlin/androidx/compose/ui/platform/AbstractComposeView)` Install this strategy for `https://developer.android.com/reference/kotlin/androidx/compose/ui/platform/ViewCompositionStrategy#installFor(androidx.compose.ui.platform.AbstractComposeView)` and return a function that will uninstall it later. | android |

## Public constructors

### DisposeOnLifecycleDestroyed

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

```
DisposeOnLifecycleDestroyed(lifecycle: Lifecycle)
```

### DisposeOnLifecycleDestroyed

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

```
DisposeOnLifecycleDestroyed(lifecycleOwner: LifecycleOwner)
```

## Public functions

### installFor

android

```
open fun installFor(view: AbstractComposeView): () -> Unit
```

Install this strategy for `https://developer.android.com/reference/kotlin/androidx/compose/ui/platform/ViewCompositionStrategy#installFor(androidx.compose.ui.platform.AbstractComposeView)` and return a function that will uninstall it later. This function should not be called directly; it is called by `https://developer.android.com/reference/kotlin/androidx/compose/ui/platform/AbstractComposeView#setViewCompositionStrategy(androidx.compose.ui.platform.ViewCompositionStrategy)` after uninstalling the previous strategy.