Node

abstract class Node

A long-lived node a modifier entry is backed by, mirroring androidx.compose.ui.Modifier.Node.

A node is attached to its component's composition before onAttach runs, and detached after onDetach returns. coroutineScope and the capabilities bound to this type, such as observeReads, are available only in between.

A chain attaches and detaches whole: while any node of the chain runs onAttach or onDetach, every node of the chain is attached, so a node may measure or paint its component whatever its place in the chain. The chain is the component's whole modifier, with the nodes of both families; a key change detaches and attaches again only the ComponentNodes.

The library builds two families on it: ComponentNode, which writes onto its component, and ParentLayoutNode, which the parent's layout manager interprets.

Inheritors

Properties

Link copied to clipboard
val coroutineScope: CoroutineScope

A scope that runs for as long as this node is attached, on the composition's own coroutine context and frame clock. Created on first access and cancelled once onDetach returns.

Link copied to clipboard

Whether this node is attached to a composition.

Link copied to clipboard

Whether an element update or composition-local refresh automatically invalidates the consumer of this node's state. A parent-layout node invalidates its measuring parent; a component node invalidates its component's DeclaredNodesListener. true by default.

Functions

Link copied to clipboard
open fun onAttach()

Runs once every node of the chain is attached. Runs again only after onDetach.

Link copied to clipboard
open fun onDetach()

Runs when the entry leaves the modifier or the node is released, deactivated or reused, while every node of its chain is still attached.

Link copied to clipboard
open fun onReset()

Runs while the node is attached, right before the composition reuses its component for different content or deactivates it. Drop state tied to the old content; onDetach follows.

Link copied to clipboard

Visits the nodes of the modifier this node is attached in that hold a place in it, in the order the modifier declares them: every ComponentNode of an additive element, and every ParentLayoutNode. This node is among them if it is one of those. Visits nothing while this node is not attached.