WorkflowLifecycleOwner

An extension of LifecycleOwner that is always owned by a View, is logically a child lifecycle of the next-nearest LifecycleOwner above it (it mirrors its parent's lifecycle until it's destroyed), and can be asked to destroy itself early.

This type is meant to help integrate with LifecycleOwner by allowing the creation of a tree of LifecycleOwners that mirrors the view tree.

Custom container views that use ScreenViewFactory.startShowing to create their children must ensure they call destroyOnDetach on the outgoing view before they replace children with new views. If this is not done, then certain processes that are started by that view's subtree may continue to run long after the view has been detached, and memory and other resources may be leaked. Note that WorkflowViewStub takes care of this chore itself.

Set a WorkflowLifecycleOwner on a view by calling installOn, and read it back using get.

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
abstract val lifecycle: Lifecycle

Functions

Link copied to clipboard
abstract fun destroyOnDetach()

If the owning view is attached, flags this lifecycle to be set to DESTROYED as soon as the owning view is detached. If the view is not attached (either because it's never been attached, or because it was attached and then detached), then it will destroy the lifecycle immediately.