Node

open class Node<T : Component>

The stateful counterpart of an NodeElement, created once per slot and kept across recompositions.

The applier injects the already-typed target component, calls onAttach once, then calls the owning NodeElement's update to push the latest data onto the node's fields - so a listener installed in onAttach is live before the first update lands, and every field it reads needs an initial value that stands until then. onDetach runs symmetrically when the element leaves the modifier or the node is released/reused, to restore a captured original or remove an installed listener.

Subclass this to back a custom NodeElement: capture the property's original in a field in onAttach, write the new value in update, and restore it in onDetach. See docs/CUSTOM-COMPONENTS.md.

Constructors

Link copied to clipboard
constructor()

Properties

Link copied to clipboard

The typed target, valid from onAttach until onDetach. Reading it outside that window - before the node is attached, or after it has been detached - fails.

Functions

Link copied to clipboard
open fun onAttach()

Runs once, after the component is injected, to install listeners or capture originals.

Link copied to clipboard
open fun onDetach()

Runs once, when the element leaves the modifier or the node is released/reused.