{% setvar book_path %}/reference/androidx/_book.yaml{% endsetvar %} {% include "_shared/_reference-head-tags.html" %}

ViewCompositionStrategy.DisposeOnLifecycleDestroyed

public final class ViewCompositionStrategy.DisposeOnLifecycleDestroyed implements ViewCompositionStrategy


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

Public methods

@NonNull Function0<Unit>

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

Public constructors

DisposeOnLifecycleDestroyed

public DisposeOnLifecycleDestroyed(@NonNull Lifecycle lifecycle)

DisposeOnLifecycleDestroyed

public DisposeOnLifecycleDestroyed(@NonNull LifecycleOwner lifecycleOwner)

Public methods

installFor

public @NonNull Function0<UnitinstallFor(@NonNull AbstractComposeView view)

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.