Skip to content

//workflow/com.squareup.workflow1.ui.androidx/WorkflowLifecycleOwner

WorkflowLifecycleOwner

[androidJvm] @WorkflowUiExperimentalApi()

interface WorkflowLifecycleOwner : LifecycleOwner

An extension of LifecycleOwner that is always owned by a View, is logically a child lifecycle of the next-nearest ViewTreeLifecycleOwner 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 ViewTreeLifecycleOwner by allowing the creation of a tree of LifecycleOwners that mirrors the view tree.

Custom container views that use ViewRegistry.buildView 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

Name Summary
Companion [androidJvm]
Content
object Companion


Functions

Name Summary
destroyOnDetach [androidJvm]
Content
abstract fun destroyOnDetach()
More info
If the owning view is attached, flags this lifecycle to be set to DESTROYED as soon as the owning view is detached.


getLifecycle [androidJvm]
Content
@NonNull()

abstract fun getLifecycle(): Lifecycle