Root

class Root(owner: Any?) : LifecycleGraph

Constructors

Link copied to clipboard
fun Root(owner: Any?)

Functions

Link copied to clipboard
fun addChild(child: LifecycleGraph.Node)

Adds child as a dependent lifecycle sharing the same scope and attachment status as this instance.

Link copied to clipboard
fun addChildren(childrenToAdd: Collection<LifecycleGraph.Node>)
Link copied to clipboard
fun addListener(listener: LifecycleListener): CancellationToken
Link copied to clipboard
fun attach(scope: CoroutineScope): CancellationToken

Attach this lifecycle instance to a coroutine scope the method has been called in.

Link copied to clipboard
fun dumpTree(): String
Link copied to clipboard
fun hasChild(child: LifecycleGraph.Node): Boolean
Link copied to clipboard
fun onDidAttach(validity: LifecycleListener.Validity = LifecycleListener.Validity.Infinite, listener: () -> Unit): CancellationToken

Registers listener for the DidAttach event.

Link copied to clipboard
fun onDidDetach(validity: LifecycleListener.Validity = LifecycleListener.Validity.Infinite, listener: () -> Unit): CancellationToken

Registers listener for the DidDetach event.

Link copied to clipboard
fun onWillAttach(validity: LifecycleListener.Validity = LifecycleListener.Validity.Infinite, listener: () -> Unit): CancellationToken

Registers listener for the WillAttach event.

Link copied to clipboard
fun onWillDetach(validity: LifecycleListener.Validity = LifecycleListener.Validity.Infinite, listener: () -> Unit): CancellationToken

Registers listener for the WillDetach event.

Link copied to clipboard
fun removeChild(child: LifecycleGraph.Node)
Link copied to clipboard
fun removeChildren(childrenToRemove: Collection<Lifecycle>)
Link copied to clipboard
fun removeListener(listener: LifecycleListener)
Link copied to clipboard
fun runOnceIfAttached(runner: suspend CoroutineScope.() -> Unit): Boolean

Launches runner right away if attached, does nothing otherwise.

Link copied to clipboard
fun topMostNode(): LifecycleGraph
Link copied to clipboard
fun whileAttached(runner: suspend CoroutineScope.() -> Unit): CancellationToken

Registers runner to be launched each time this lifecycle is attached to a scope and cancelled once detached.

Properties

Link copied to clipboard
val debugDescription: String
Link copied to clipboard
val isAttached: Boolean

Extensions

Link copied to clipboard
fun LifecycleGraph.Root.attachToMainScope(): CancellationToken
fun LifecycleGraph.Root.attachToMainScope(unhandledExceptionHandler: (CoroutineContext, Throwable) -> Unit): CancellationToken