Android 12 Developer Preview is here! Try it out, and give us your feedback!

DisposeOnLifecycleDestroyed

class DisposeOnLifecycleDestroyed : ViewCompositionStrategy
kotlin.Any
   ↳ androidx.compose.ui.platform.ViewCompositionStrategy.DisposeOnLifecycleDestroyed

ViewCompositionStrategy that disposes the composition when lifecycle is destroyed. This strategy is appropriate for Compose UI views that share a 1-1 relationship with a known LifecycleOwner.

Summary

Public constructors
<init>(lifecycleOwner: LifecycleOwner)

<init>(lifecycle: Lifecycle)

ViewCompositionStrategy that disposes the composition when lifecycle is destroyed.

Public methods
() -> Unit

Install this strategy for view and return a function that will uninstall it later.

Public constructors

<init>

DisposeOnLifecycleDestroyed(lifecycleOwner: LifecycleOwner)

<init>

DisposeOnLifecycleDestroyed(lifecycle: Lifecycle)

ViewCompositionStrategy that disposes the composition when lifecycle is destroyed. This strategy is appropriate for Compose UI views that share a 1-1 relationship with a known LifecycleOwner.

Public methods

installFor

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

Install this strategy for view and return a function that will uninstall it later. This function should not be called directly; it is called by AbstractComposeView.setViewCompositionStrategy after uninstalling the previous strategy.