Composer Lite
Coordinates transactional, group-based incremental composition without compiler-generated flags.
runGroup builds a positional scope tree in slotTable. A committed group result is reused when its explicit inputs are equal and none of its observed state has invalidated the scope. State invalidations are coalesced in invalidationQueue. Composition runs in a pinned read Snapshot and prepareRoot lets a host commit or roll back runtime changes together with another mutable tree.
Composer instances are thread-confined. Calls that compose, commit, abort, run effects, or dispose an instance MUST be serialized by its owner.
Parameters
scope/slot tree owned by this composer
queue that coalesces state-driven scope invalidations
optional sink for structural-drift warnings, emitted once per drift location
optional callback invoked when a clean scope first becomes dirty; repeated invalidations before the next composition are coalesced
optional formatter for opaque local snapshots included in diagnostics
optional collector invoked only when a new scope is created
Samples
val count = mutableStateOf(0)
val committedValues = mutableListOf<String>()
val composer = ComposerLite()
fun compose(): String = composer.composeRoot {
composer.runGroup(signature = "counter") { _ ->
val prefix = composer.remember(keys = emptyList()) { "Count" }
"$prefix: ${count.value}".also { value ->
composer.sideEffect { committedValues += value }
}
}
}
check(compose() == "Count: 0")
composer.commitSideEffects()
count.value = 1
check(composer.hasPendingInvalidations())
check(compose() == "Count: 1")
composer.commitSideEffects()
check(committedValues == listOf("Count: 0", "Count: 1"))
composer.dispose()Constructors
Types
Functions
Runs all effect operations queued by committed compositions.
Composes block, commits the runtime transaction, and returns its candidate value.
Registers a keyed effect in the next positional effect slot of the current scope.
Removes and returns queued state invalidations after ancestor compaction.
Returns whether state-driven scope invalidations are waiting in the queue.
Returns a deterministic key for the next positional saveable slot in the current scope.
Composes a candidate root result without finalizing scope, observation, or effect changes.
Marks the root dirty for the next composition attempt.
Registers effect to run once after the current composition commits.