SwingNodeUpdater

Receiver of a SwingNode update block. The typed component T is this in its operations.

Functions

Link copied to clipboard
fun applyMirror(mirror: MirrorState<*>)

Applies mirror to this node, so the mirror belongs to it - which is what lets MirrorState.report answer a change inside the event that made it rather than from an event of its own.

Link copied to clipboard
fun <C : Component, V> SwingNodeUpdater<C>.declare(value: V, mirror: MirrorState<V>, read: C.() -> V, write: C.(V) -> Unit, onSettled: C.(V) -> Unit = {})

Declares value onto a widget property the user can also change, keeping mirror in sync with it.

fun <C : Component, V> SwingNodeUpdater<C>.declare(value: V, mirror: MirrorState<V>, read: C.() -> V, write: C.(held: V, declared: V) -> Unit, onSettled: C.(V) -> Unit = {})

Declares value onto a widget property whose write is a transition rather than an assignment: write is handed what the widget holds alongside what is declared, so it can write only the part that differs and leave what the rest of the value anchors standing - the caret inside a document, above all. The held value is the one the settlement has already read, so the write costs no second read.

Link copied to clipboard
inline fun init(crossinline block: T.() -> Unit)

Runs block, with the typed component as this, exactly once: on the pass that creates the node, after the set/update blocks declared above it in the same update lambda have run against the freshly built component. Use it for setup that must happen once at creation but needs a value set/update computed - a value the factory cannot see - and that reconcile would otherwise redo on every composition.

Link copied to clipboard
inline fun reconcile(crossinline block: T.() -> Unit)

Unconditionally schedules block to run against the typed component on every composition. Prefer set/update when a single changing value drives the update; reach for reconcile only when those are insufficient.

Link copied to clipboard

Reconciles block against this node's children, at the end of the change pass rather than here.

Link copied to clipboard
inline fun <V> set(value: V, crossinline block: T.(V) -> Unit)

Reactively applies value to the component. block runs, with the typed component as this and value as its argument, on the first composition and again only when value changes between recompositions.

Link copied to clipboard
inline fun <V> update(value: V, crossinline block: T.(V) -> Unit)

Reactively applies value to the component, but - unlike set - skips the very first composition. Use it when the factory already initialized the component with value (e.g. a constructor argument).