Object

ViewCompositionStrategy.DisposeOnDetachedFromWindow

ViewCompositionStrategy that disposes the composition whenever the view becomes detached from a window.

RevenueCat

RevenueCat

Add subscriptions to your apps in minutes

Ad Get started for free
Android
object DisposeOnDetachedFromWindow : ViewCompositionStrategy

ViewCompositionStrategy that disposes the composition whenever the view becomes detached from a window. If the user of a Compose UI view never explicitly calls AbstractComposeView.createComposition, this strategy is always safe and will always clean up composition resources with no explicit action required - just use the view like any other View and let garbage collection do the rest. (If AbstractComposeView.createComposition is called while the view is detached from a window, AbstractComposeView.disposeComposition must be called manually if the view is not later attached to a window.)