Google is committed to advancing racial equity for Black communities. See how.

Composer

class Composer<N>
kotlin.Any
   ↳ androidx.compose.runtime.Composer

Implementation of a composer for mutable tree.

Summary

Public constructors
<init>(applier: Applier<N>, parentReference: CompositionReference)

Implementation of a composer for mutable tree.

Public methods
Unit

Apply the changes to the tree that were collected during the last composition.

T
cache(invalid: Boolean, block: () -> T)

Cache a value in the composition.

Boolean
changed(value: Any?)

Determine if the current slot table value is equal to the given value, if true, the value is scheduled to be skipped during applyChanges and changes return false; otherwise applyChanges will update the slot table to value.

Boolean
changed(value: Char)

Boolean
changed(value: Byte)

Boolean
changed(value: Short)

Boolean
changed(value: Boolean)

Boolean
changed(value: Float)

Boolean
changed(value: Long)

Boolean
changed(value: Double)

Boolean
changed(value: Int)

Unit

Start collecting key source information.

Unit

Start collecting parameter information.

Unit
composeInitial(block: () -> Unit)

Synchronously compose the initial composition of block.

Unit

Warning: This is expected to be executed by the compiler only and should not be called directly from source code.

Unit

Indicates the end of a "Movable Group" at the current execution position.

Unit

Indicates the end of a "Replaceable Group" at the current execution position.

ScopeUpdateScope?

End a restart group.

Any
joinKey(left: Any?, right: Any?)

Create a composed key that can be used in calls to startGroup or startNode.

Boolean

Synchronously recompose all invalidated groups.

Unit

Record that the objects in values have been modified.

Unit
recordReadOf(value: Any)

Record that value was read from.

Unit

Record that value was written to during composition.

Unit

Skip a group.

Unit

Skip to the end of the group opened by startGroup.

Unit

Warning: This is expected to be executed by the compiler only and should not be called directly from source code.

Unit
startMovableGroup(key: Int, dataKey: Any?)

Inserts a "Movable Group" starting marker in the slot table at the current execution position.

Unit
startMovableGroup(key: Int, dataKey: Any?, sourceInformation: String?)

Unit

Inserts a "Replaceable Group" starting marker in the slot table at the current execution position.

Unit
startReplaceableGroup(key: Int, sourceInformation: String?)

Unit

Start a restart group.

Unit
startRestartGroup(key: Int, sourceInformation: String?)

Unit

Throw a diagnostic exception if the internal tracking tables are inconsistent.

Extension functions
From androidx.compose.ui
Modifier

Materialize any instance-specific composed modifiers for applying to a raw tree node.

Properties
CoroutineContext

CompositionData

Int

Returns the hash of the compound key calculated as a combination of the keys of all the currently started groups via startGroup.

Boolean

Boolean

True if the composition should be checking if the composable functions can be skipped.

Public constructors

<init>

Composer(
    applier: Applier<N>,
    parentReference: CompositionReference)

Implementation of a composer for mutable tree.

Public methods

applyChanges

fun applyChanges(): Unit

Apply the changes to the tree that were collected during the last composition.

cache

inline fun <T> cache(
    invalid: Boolean,
    block: () -> T
): T

Cache a value in the composition. During initial composition block is called to produce the value that is then stored in the slot table. During recomposition, if invalid is false the value is obtained from the slot table and block is not invoked. If invalid is false a new value is produced by calling block and the slot table is updated to contain the new value.

changed

fun changed(value: Any?): Boolean

Determine if the current slot table value is equal to the given value, if true, the value is scheduled to be skipped during applyChanges and changes return false; otherwise applyChanges will update the slot table to value. In either case the composer's slot table is advanced.

Parameters
value: Any? the value to be compared.

changed

fun changed(value: Char): Boolean

changed

fun changed(value: Byte): Boolean

changed

fun changed(value: Short): Boolean

changed

fun changed(value: Boolean): Boolean

changed

fun changed(value: Float): Boolean

changed

fun changed(value: Long): Boolean

changed

fun changed(value: Double): Boolean

changed

fun changed(value: Int): Boolean

collectKeySourceInformation

fun collectKeySourceInformation(): Unit

Start collecting key source information. This enables enables the tool API to be able to determine the source location of where groups and nodes are created.

collectParameterInformation

fun collectParameterInformation(): Uni