KillableLifecycleOwner

class KillableLifecycleOwner(parentLifecycleOwner: LifecycleOwner, mainScopeProvider: MainScopeProvider) : LifecycleOwner

LifecycleOwner which is destroyed when it catches a DeadObjectException.

Shadows the parentLifecycleOwner. Use invokeDeathSafe to catch the DeadObjectException and handle it. Use invokeDeathSafeThrow to handle the DeadObjectException and rethrow it.

Parameters

mainScopeProvider

Called to post the given action on the main thread.

Constructors

Link copied to clipboard
fun KillableLifecycleOwner(parentLifecycleOwner: LifecycleOwner, mainScopeProvider: MainScopeProvider)

Functions

Link copied to clipboard
open override fun getLifecycle(): Lifecycle
Link copied to clipboard
fun invokeDeathSafe(action: () -> Unit)

Invokes action and destroys the lifecycle owner when it throws a DeadObjectException.

Link copied to clipboard
fun <R> invokeDeathSafeThrow(action: () -> R): R

Invokes action and destroys the lifecycle owner when it throws a DeadObjectException.