ViewCompositionStrategy.DisposeOnDetachedFromWindow


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.)

Summary

Public functions

open () -> Unit

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

android

Public functions

installFor

open 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.