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

ViewCompositionStrategy.DisposeOnViewTreeLifecycleDestroyed

public static class ViewCompositionStrategy.DisposeOnViewTreeLifecycleDestroyed implements ViewCompositionStrategy


ViewCompositionStrategy that disposes the composition when the LifecycleOwner returned by findViewTreeLifecycleOwner of the next window the view is attached to is destroyed. This strategy is appropriate for Compose UI views that share a 1-1 relationship with their closest LifecycleOwner, such as a Fragment view.

Summary

Public fields

static @NonNull ViewCompositionStrategy.DisposeOnViewTreeLifecycleDestroyed

Public methods

@NonNull Function0<Unit>

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

Public fields

INSTANCE

public static @NonNull ViewCompositionStrategy.DisposeOnViewTreeLifecycleDestroyed INSTANCE

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.