OnDemandComposition

class OnDemandComposition(parent: CompositionContext, content: @Composable () -> Unit) : DisposableHandle

A composition of Swing content under parent. It recomposes when parent snapshot state it reads changes. recompose drives its own synchronous pass on the caller's thread before returning, without waiting for the enclosing window's frame loop.

content's one top-level component is handed to the caller by recompose rather than added to a container - this composition places nothing of its own. Content that composes more than one top-level component is refused with IllegalStateException, since there would be no single component to hand back; composing it for the first time on construction is held to the same rule. Any later refusal disposes the composition before it is reported.

content shares parent's state and CompositionLocals.

Must be constructed, recomposed, and disposed on the Event Dispatch Thread.

Parameters

parent

the composition context this composition joins.

content

content composed on construction and by recompose.

Constructors

Link copied to clipboard
constructor(parent: CompositionContext, content: @Composable () -> Unit)

Functions

Link copied to clipboard
open override fun dispose()

Disposes this composition. A recompose over it stays safe to invoke afterwards, answering null the way a composition holding nothing composes none.

Link copied to clipboard
fun recompose(update: () -> Unit): Component?

Runs update, then recomposes and applies this composition synchronously, so its Swing subtree is fully materialized before this returns. The write is recorded against this composition so the synchronous recompose sees the change; this takes no frame from a window recomposer.