Composer


Composer is the interface that is targeted by the Compose Kotlin compiler plugin and used by code generation helpers. It is highly recommended that direct calls these be avoided as the runtime assumes that the calls are generated by the compiler and contain only a minimum amount of state validation.

Summary

Public companion functions

Unit

Internal API for specifying a tracer used for instrumenting frequent operations, e.g. recompositions.

Cmn

Public companion properties

Any

A special value used to represent no value was stored (e.g. an empty slot).

Cmn

Public functions

Unit
@ComposeCompilerApi
<V : Any?, T : Any?> apply(value: V, block: T.(V) -> Unit)

A Compose compiler plugin API.

Cmn
CompositionContext

A Compose internal function.

Cmn
Boolean

A Compose compiler plugin API.

Cmn
open Boolean

A Compose compiler plugin API.

Cmn
open Boolean

A Compose compiler plugin API.

Cmn
open Boolean

A Compose compiler plugin API.

Cmn
open Boolean

A Compose compiler plugin API.

Cmn
open Boolean

A Compose compiler plugin API.

Cmn
open Boolean

A Compose compiler plugin API.

Cmn
open Boolean

A Compose compiler plugin API.

Cmn
open Boolean

A Compose compiler plugin API.

Cmn
open Boolean

A Compose compiler plugin API.

Cmn
Unit

A tooling API function.

Cmn
T

A Compose internal function.

Cmn
Unit
@ComposeCompilerApi
<T : Any?> createNode(factory: () -> T)

A Compose compiler plugin API.

Cmn
Unit

A Compose compiler plugin API.

Cmn
Unit

A Compose compiler plugin API.

Cmn
Unit

Disable the collection of source information, that may introduce groups to store the source information, in order to be able to more accurately calculate the actual number of groups a composable function generates in a release build.

Cmn
Unit

A Compose compiler plugin API.

Cmn
Unit

A Compose compiler plugin API.

Cmn
Unit

A Compose compiler plugin API.

Cmn
Unit

A Compose compiler plugin API.

Cmn
Unit

A Compose internal function.

Cmn
Unit

A Compose internal function.

Cmn
Unit

A Compose compiler plugin API.

Cmn
Unit

A Compose compiler plugin API.

Cmn
ScopeUpdateScope?

A Compose compiler plugin API.

Cmn
Unit

A Compose compiler plugin API.

Cmn
Unit

Compose compiler plugin API.

Cmn
Unit

A Compose internal API.

Cmn
Unit

A Compose internal API.

Cmn
Any
@ComposeCompilerApi
joinKey(left: Any?, right: Any?)

A Compose compiler plugin API.

Cmn
Unit

A Compose internal function.

Cmn
Unit

A Compose compiler plugin API.

Cmn
Any?

A Compose compiler plugin API.

Cmn
Boolean
@InternalComposeApi
shouldExecute(parametersChanged: Boolean, flags: Int)

A Compose compiler plugin API.

Cmn
Unit

A Compose compiler plugin API.

Cmn
Unit

A Compose compiler plugin API.

Cmn
Unit
sourceInformation(sourceInformation: String)

A Compose compiler plugin API.

Cmn
Unit

A compose compiler plugin API.

Cmn
Unit
sourceInformationMarkerStart(key: Int, sourceInformation: String)

A compose compiler plugin API.

Cmn
Unit

A Compose compiler plugin API.

Cmn
Unit

A Compose compiler plugin API.

Cmn
Unit

A Compose compiler plugin API.

Cmn
Unit

A Compose internal function.

Cmn
Unit

A Compose internal function.

Cmn
Unit

A Compose compiler plugin API.

Cmn
Unit

A Compose compiler plugin API.

Cmn
Composer

A Compose compiler plugin API.

Cmn
Unit

A Compose compiler plugin API.

Cmn
Unit

A Compose compiler plugin API.

Cmn
Unit

A Compose compiler plugin API.

Cmn
Unit

A Compose compiler plugin API.

Cmn

Public properties

Applier<*>

A Compose compiler plugin API.

Cmn
CoroutineContext

A Compose internal function.

Cmn
ControlledComposition

The composition that is used to control this composer.

Cmn
CompositionData

A tooling API function.

Cmn
Int

A Compose internal property.

Cmn
CompositionLocalMap

Returns the active set of CompositionLocals at the current position in the composition hierarchy.

Cmn
Int

A Compose compiler plugin API.

Cmn
Boolean

A Compose compiler plugin API.

Cmn
Boolean

A Compose compiler plugin API.

Cmn
RecomposeScope?

A Compose internal property.

Cmn
Any?

A Compose compiler plugin API.

Cmn
Boolean

A Compose compiler plugin API.

Cmn

Extension functions

Modifier

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

Cmn
inline T
@ComposeCompilerApi
<T : Any?> Composer.cache(
    invalid: Boolean,
    block: @DisallowComposableCalls () -> T
)

A Compose compiler plugin API.

Cmn

Public companion functions

setTracer

@InternalComposeTracingApi
fun setTracer(tracer: CompositionTracer?): Unit

Internal API for specifying a tracer used for instrumenting frequent operations, e.g. recompositions.

Public companion properties

Empty

val EmptyAny

A special value used to represent no value was stored (e.g. an empty slot). This is returned, for example by Composer.rememberedValue while it is Composer.inserting is true.

Public functions

apply

@ComposeCompilerApi
fun <V : Any?, T : Any?> apply(value: V, block: T.(V) -> Unit): Unit

A Compose compiler plugin API. DO NOT call directly.

Schedule block to called with value. This is intended to update the node generated by createNode to changes discovered by composition.

Parameters
value: V

the new value to be set into some property of the node.

block: T.(V) -> Unit

the block that sets the some property of the node to value.

buildContext

@InternalComposeApi
fun buildContext(): CompositionContext

A Compose internal function. DO NOT call directly.

Build a composition context that can be used to created a subcomposition. A composition reference is used to communicate information from this composition to the subcompositions such as the all the CompositionLocals provided at the point the reference is created.

changed

@ComposeCompilerApi
fun changed(value: Any?): Boolean

A Compose compiler plugin API. DO NOT call directly.

Check value is different than the value used in the previous composition. This is used, for example, to check parameter values to determine if they have changed.

Parameters
value: Any?

the value to check

Returns
Boolean

true if the value if equals of the previous value returns false when passed value.

changed

@ComposeCompilerApi
open fun changed(value: Boolean): Boolean

A Compose compiler plugin API. DO NOT call directly.

Check value is different than the value used in the previous composition. This is used, for example, to check parameter values to determine if they have changed.

This overload is provided to avoid boxing value to compare with a potentially boxed version of value in the composition state.

Parameters
value: Boolean

the value to check

Returns
Boolean

true if the value if equals of the previous value returns false when passed value.

changed

@ComposeCompilerApi
open fun changed(value: Byte): Boolean

A Compose compiler plugin API. DO NOT call directly.

Check value is different than the value used in the previous composition. This is used, for example, to check parameter values to determine if they have changed.

This overload is provided to avoid boxing value to compare with a potentially boxed version of value in the composition state.

Parameters
value: Byte

the value to check

Returns
Boolean

true if the value if equals of the previous value returns false when passed value.

changed

@ComposeCompilerApi
open fun changed(value: Char): Boolean

A Compose compiler plugin API. DO NOT call directly.

Check value is different than the value used in the previous composition. This is used, for example, to check parameter values to determine if they have changed.

This overload is provided to avoid boxing value to compare with a potentially boxed version of value in the composition state.

Parameters
value: Char

the value to check

Returns
Boolean

true if the value if equals of the previous value returns false when passed value.

changed

@ComposeCompilerApi
open fun changed(value: Double): Boolean

A Compose compiler plugin API. DO NOT call directly.

Check value is different than the value used in the previous composition. This is used, for example, to check parameter values to determine if they have changed.

This overload is provided to avoid boxing value to compare with a potentially boxed version of value in the composition state.

Parameters
value: Double

the value to check

Returns
Boolean

true if the value if equals of the previous value returns false when passed value.

changed

@ComposeCompilerApi
open fun changed(value: Float): Boolean

A Compose compiler plugin API. DO NOT call directly.

Check value is different than the value used in the previous composition. This is used, for example, to check parameter values to determine if they have changed.

This overload is provided to avoid boxing value to compare with a potentially boxed version of value in the composition state.

Parameters
value: Float

the value to check

Returns
Boolean

true if the value if equals of the previous value returns false when passed value.

changed

@ComposeCompilerApi
open fun changed(value: Int): Boolean

A Compose compiler plugin API. DO NOT call directly.

Check value is different than the value used in the previous composition. This is used, for example, to check parameter values to determine if they have changed.

This overload is provided to avoid boxing value to compare with a potentially boxed version of value in the composition state.

Parameters
value: Int

the value to check

Returns
Boolean

true if the value if equals of the previous value returns false when passed value.

changed

@ComposeCompilerApi
open fun changed(value: Long): Boolean

A Compose compiler plugin API. DO NOT call directly.

Check value is different than the value used in the previous composition. This is used, for example, to check parameter values to determine if they have changed.

This overload is provided to avoid boxing value to compare with a potentially boxed version of value in the composition state.

Parameters
value: Long

the value to check

Returns
Boolean

true if the value if equals of the previous value returns false when passed value.

changed

@ComposeCompilerApi
open fun changed(value: Short): Boolean

A Compose compiler plugin API. DO NOT call directly.

Check value is different than the value used in the previous composition. This is used, for example, to check parameter values to determine if they have changed.

This overload is provided to avoid boxing value to compare with a potentially boxed version of value in the composition state.

Parameters
value: Short

the value to check

Returns
Boolean

true if the value if equals of the previous value returns false when passed value.

changedInstance

@ComposeCompilerApi
open fun changedInstance(value: Any?): Boolean

A Compose compiler plugin API. DO NOT call directly.

Check value is different than the value used in the previous composition using === instead of == equality. This is used, for example, to check parameter values to determine if they have changed for values that use value equality but, for correct behavior, the composer needs reference equality.

Parameters
value: Any?

the value to check

Returns
Boolean

true if the value is === equal to the previous value and returns false when value is different.

collectParameterInformation

fun collectParameterInformation(): Unit

A tooling API function. DO NOT call directly.

Called by the inspector to inform the composer that it should collect additional information about call parameters. By default, only collect parameter information for scopes that are recordUsed has been called on. If collectParameterInformation is called it will attempt to collect all calls even if the runtime doesn't need them.

WARNING: calling this will result in a significant number of additional allocations that are typically avoided.

consume

@InternalComposeApi
fun <T : Any?> consume(key: CompositionLocal<T>): T

A Compose internal function. DO NOT call directly.

Return the CompositionLocal value associated with key. This is the primitive function used to implement CompositionLocal.current.

Parameters
key: CompositionLocal<T>

the CompositionLocal value to be retrieved.

createNode

@ComposeCompilerApi
fun <T : Any?> createNode(factory: () -> T): Unit

A Compose compiler plugin API. DO NOT call directly.

Report the factory that will be used to create the node that will be generated into the tree implied by the composition. This will only be called if inserting is is true.

Parameters
factory: () -> T

a factory function that will generate a node that will eventually be supplied to applier though Applier.insertBottomUp and Applier.insertTopDown.

deactivateToEndGroup

@ComposeCompilerApi
fun deactivateToEndGroup(changed: Boolean): Unit

A Compose compiler plugin API. DO NOT call directly.

Deactivates the content to the end of the group by treating content as if it was deleted and replaces all slot table entries for calls to cache to be Empty. This must be called as the first call for a group.

disableReusing

@ComposeCompilerApi
fun disableReusing(): Unit

A Compose compiler plugin API. DO NOT call directly.

Temporarily disable reusing if it is enabled.

disableSourceInformation

@TestOnly
fun disableSourceInformation(): Unit

Disable the collection of source information, that may introduce groups to store the source information, in order to be able to more accurately calculate the actual number of groups a composable function generates in a release build.

This function is only safe to call in a test and will produce incorrect composition results if called on a composer not under test.

enableReusing

@ComposeCompilerApi
fun enableReusing(): Unit

A Compose compiler plugin API. DO NOT call directly.

Reenable reusing if it was previously enabled before the last call to disableReusing.

endDefaults

@ComposeCompilerApi
fun endDefaults(): Unit

A Compose compiler plugin API. DO NOT call directly.

Called at the end of defaults group.

See also
startDefaults

endMovableGroup

@ComposeCompilerApi
fun endMovableGroup(): Unit

A Compose compiler plugin API. DO NOT call directly.

Called at the end of a movable group.

endNode

@ComposeCompilerApi
fun endNode(): Unit

A Compose compiler plugin API. DO NOT call directly.

Called at the end of a node group.

endProvider

@InternalComposeApi
fun endProvider(): Unit

A Compose internal function. DO NOT call directly.

End the provider group.

See also
startProvider

endProviders

@InternalComposeApi
fun endProviders(): Unit

A Compose internal function. DO NOT call directly.

End the provider group.

See also
startProviders

endReplaceGroup

@ComposeCompilerApi
fun endReplaceGroup(): Unit

A Compose compiler plugin API. DO NOT call directly.

Called at the end of a replace group.

endReplaceableGroup

@ComposeCompilerApi
fun endReplaceableGroup(): Unit

A Compose compiler plugin API. DO NOT call directly.

Called at the end of a replaceable group.

endRestartGroup

@ComposeCompilerApi
fun endRestartGroup(): ScopeUpdateScope?

A Compose compiler plugin API. DO NOT call directly.

Called to end a restart group.

endReusableGroup

@ComposeCompilerApi
fun endReusableGroup(): Unit

A Compose compiler plugin API. DO NOT call directly.

Called at the end of a reusable group.

endToMarker

@ComposeCompilerApi
fun endToMarker(marker: Int): Unit

Compose compiler plugin API. DO NOT call directly.

Ends all the groups up to but not including the group that is the parent group when currentMarker was called to produce marker. All groups ended must have been started with either startReplaceableGroup or startMovableGroup. Ending other groups can cause the state of the composer to become inconsistent.

insertMovableContent

@InternalComposeApi
fun insertMovableContent(value: MovableContent<*>, parameter: Any?): Unit

A Compose internal API. DO NOT call directly.

Request movable content be inserted at the current location. This will schedule with the root composition parent a call to insertMovableContent with the correct MovableContentState if one was released in another part of composition.

insertMovableContentReferences

@InternalComposeApi
fun insertMovableContentReferences(
    references: List<Pair<MovableContentStateReferenceMovableContentStateReference?>>
): Unit

A Compose internal API. DO NOT call directly.

Perform a late composition that adds to the current late apply that will insert the given references to MovableContent into the composition. If a MovableContent is paired then this is a request to move a released MovableContent from a different location or from a different composition. If it is not paired (i.e. the second MovableContentStateReference is null) then new state for the MovableContent is inserted into the composition.

joinKey

@ComposeCompilerApi
fun joinKey(left: Any?, right: Any?): Any

A Compose compiler plugin API. DO NOT call directly.

Produce an object that will compare equal an iff left and right compare equal to some left and right of a previous call to joinKey. This is used by key to handle multiple parameters. Since the previous composition stored left and right in a "join key" object this call is used to return the previous value without an allocation instead of blindly creating a new value that will be immediately discarded.

Parameters
left: Any?

the first part of a a joined key.

right: Any?

the second part of a joined key.

Returns
Any

an object that will compare equal to a value previously returned by joinKey iff left and right compare equal to the left and right passed to the previous call.

recordSideEffect

@InternalComposeApi
fun recordSideEffect(effect: () -> Unit): Unit

A Compose internal function. DO NOT call directly.

Record a function to call when changes to the corresponding tree are applied to the applier. This is used to implement SideEffect.

Parameters
effect: () -> Unit

a lambda to invoke after the changes calculated up to this point have been applied.

recordUsed

@InternalComposeApi
fun recordUsed(scope: RecomposeScope): Unit

A Compose compiler plugin API. DO NOT call directly.

Mark scope as used. endReplaceableGroup will return null unless recordUsed is called on the corresponding scope. This is called implicitly when State objects are read during composition is called when currentRecomposeScope is called in the Composable function.

rememberedValue

@ComposeCompilerApi
fun rememberedValue(): Any?

A Compose compiler plugin API. DO NOT call directly.

Remember a value into the composition state. This is a primitive method used to implement remember.

Returns
Any?

Composer.Empty when inserting is true or the value passed to updateRememberedValue from the previous composition.

See also
cache

shouldExecute

@InternalComposeApi
fun shouldExecute(parametersChanged: Boolean, flags: Int): Boolean

A Compose compiler plugin API. DO NOT call directly.

Generated by the compile to determine if the composable function should be executed. It may not execute if parameter has not changed and the nothing else is forcing the function to execute (such as its scope was invalidated or a static composition local it was changed) or the composition is pausable and the composition is pausing.

Parameters
parametersChanged: Boolean

true if the parameters to the composable function have changed. This is also true if the composition is inserting or if content is being reused.

flags: Int

The $changed parameter that contains the forced recompose bit to allow the composer to disambiguate when the parameters changed due the execution being forced or if the parameters actually changed. This is only ambiguous in a PausableComposition and is necessary to determine if the function can be paused. The bits, other than 0, are reserved for future use (which would required the bit 31, which is unused in $changed values, to be set to indicate that the flags carry additional information). Passing the $changed flags directly, instead of masking the 0 bit, is more efficient as it allows less code to be generated per call to shouldExecute which is every called in every restartable function, as well as allowing for the API to be extended without a breaking changed.

skipCurrentGroup

@ComposeCompilerApi
fun skipCurrentGroup(): Unit

A Compose compiler plugin API. DO NOT call directly.

Skips the current group. This called by the compiler to indicate that the current group can be skipped, for example, this is generated to skip the startDefaults group the default group is was not invalidated.

skipToGroupEnd

@ComposeCompilerApi
fun skipToGroupEnd(): Unit

A Compose compiler plugin API. DO NOT call directly.

Skips the composer to the end of the current group. This generated by the compiler to when the body of a Composable function can be skipped typically because the parameters to the function are equal to the values passed to it in the previous composition.

sourceInformation

fun sourceInformation(sourceInformation: String): Unit

A Compose compiler plugin API. DO NOT call directly.

Record the source information string for a group. This must be immediately called after the start of a group.

Parameters
sourceInformation: String

An string value to that provides the compose tools enough information to calculate the source location of calls to composable functions.

sourceInformationMarkerEnd

fun sourceInformationMarkerEnd(): Unit

A compose compiler plugin API. DO NOT call directly.

Record the end of the marked source information range.

sourceInformationMarkerStart

fun sourceInformationMarkerStart(key: Int, sourceInformation: String): Unit

A compose compiler plugin API. DO NOT call directly.

Record a source information marker. This marker can be used in place of a group that would have contained the information but was elided as the compiler plugin determined the group was not necessary such as when a function is marked with ReadOnlyComposable.

Parameters
key: Int

A compiler generated key based on the source location of the call.

sourceInformation: String

An string value to that provides the compose tools enough information to calculate the source location of calls to composable functions.

startDefaults

@ComposeCompilerApi
fun startDefaults(): Unit

A Compose compiler plugin API. DO NOT call directly.

Called to start the group that calculates the default parameters of a Composable function.

This method is called near the beginning of a Composable function with default parameters and surrounds the remembered values or Composable calls necessary to produce the default parameters. For example, for model: Model = remember { DefaultModel() } the call to remember is called inside a startDefaults group.

startMovableGroup

@ComposeCompilerApi
fun startMovableGroup(key: Int, dataKey: Any?): Unit

A Compose compiler plugin API. DO NOT call directly.

Start a movable group. A movable group is one that can be moved based on the value of dataKey which is typically supplied by the key pseudo compiler function.

A movable group implements the semantics of key which allows the state and nodes generated by a loop to move with the composition implied by the key passed to key.

Parameters
key: Int

a compiler generated key based on the source location of the call.

dataKey: Any?

an additional object that is used as a second part of the key. This key produced from the keys parameter supplied to the key pseudo compiler function.

startNode

@ComposeCompilerApi
fun startNode(): Unit

A Compose compiler plugin API. DO NOT call directly.

Start a group that tracks a the code that will create or update a node that is generated as part of the tree implied by the composition.

startProvider

@InternalComposeApi
fun startProvider(value: ProvidedValue<*>): Unit

A Compose internal function. DO NOT call directly.

Provide the given value for the associated CompositionLocal key. This is the primitive function used to implement CompositionLocalProvider.

Parameters
value: ProvidedValue<*>

a value to provider key pairs.

startProviders

@InternalComposeApi
fun startProviders(values: Array<ProvidedValue<*>>): Unit

A Compose internal function. DO NOT call directly.

Provide the given values for the associated CompositionLocal keys. This is the primitive function used to implement CompositionLocalProvider.

Parameters
values: Array<ProvidedValue<*>>

an array of value to provider key pairs.

startReplaceGroup

@ComposeCompilerApi
fun startReplaceGroup(key: Int): Unit

A Compose compiler plugin API. DO NOT call directly.

Start a replace group. A replace group is a group that cannot be moved during must only either be inserted, removed, or replaced. For example, the group created by most control flow constructs such as an if statement are replaceable groups.

Note: This method replaces startReplaceableGroup which is only generated by older versions of the compose compiler plugin that predate the addition of this method. The runtime is now required to replace the group if a different group is detected instead of treating it like a movable group.

Parameters
key: Int

A compiler generated key based on the source location of the call.

See also
endReplaceGroup

startReplaceableGroup

@ComposeCompilerApi
fun startReplaceableGroup(key: Int): Unit

A Compose compiler plugin API. DO NOT call directly.

Start a replaceable group. A replaceable group is a group that cannot be moved during execution and can only either inserted, removed, or replaced. For example, the group created by most control flow constructs such as an if statement are replaceable groups.

Warning: Versions of the compiler that generate calls to this function also contain subtle bug that does not generate a group around a loop containing code that just creates composable lambdas (AnimatedContent from androidx.compose.animation, for example) which makes replacing the group unsafe and the this must treat this like a movable group. startReplaceGroup was added that will replace the group as described above and is only called by versions of the compiler that correctly generate code around loops that create lambdas. This method is kept to maintain compatibility with code generated by older versions of the compose compiler plugin.

Parameters
key: Int

A compiler generated key based on the source location of the call.

startRestartGroup

@ComposeCompilerApi
fun startRestartGroup(key: Int): Composer

A Compose compiler plugin API. DO NOT call directly.

Called to record a group for a Composable function and starts a group that can be recomposed on demand based on the lambda passed to updateScope when endRestartGroup is called

Parameters
key: Int

A compiler generated key based on the source location of the call.

Returns
Composer

the instance of the composer to use for the rest of the function.

startReusableGroup

@ComposeCompilerApi
fun startReusableGroup(key: Int, dataKey: Any?): Unit

A Compose compiler plugin API. DO NOT call directly.

Start a reuse group. Unlike a movable group, in a reuse group if the dataKey changes the composition shifts into a reusing state cause the composer to act like it is inserting (e.g. cache acts as if all values are invalid, changed always returns true, etc.) even though it is recomposing until it encounters a reusable node. If the node is reusable it temporarily shifts into recomposition for the node and then shifts back to reusing for the children. If a non-reusable node is generated the composer shifts to inserting for the node and all of its children.

Parameters
key: Int

An compiler generated key based on the source location of the call.

dataKey: Any?

A key provided by the ReusableContent composable function that is used to determine if the composition shifts into a reusing state for this group.

startReusableNode

@ComposeCompilerApi
fun startReusableNode(): Unit

A Compose compiler plugin API. DO NOT call directly.

Start a group that tracks a the code that will create or update a node that is generated as part of the tree implied by the composition. A reusable node can be reused in a reusable group even if the group key is changed.

updateRememberedValue

@ComposeCompilerApi
fun updateRememberedValue(value: Any?): Unit

A Compose compiler plugin API. DO NOT call directly.

Update the remembered value correspond to the previous call to rememberedValue. The value will be returned by rememberedValue for the next composition.

useNode

@ComposeCompilerApi
fun useNode(): Unit

A Compose compiler plugin API. DO NOT call directly.

Report that the node is still being used. This will be called in the same location as the corresponding createNode when inserting is false.

Public properties

applier

@ComposeCompilerApi
val applierApplier<*>

A Compose compiler plugin API. DO NOT call directly.

Changes calculated and recorded during composition and are sent to applier which makes the physical changes to the node tree implied by a composition.

Composition has two discrete phases, 1) calculate and record changes and 2) making the changes via the applier. While a Composable functions is executing, none of the applier methods are called. The recorded changes are sent to the applier all at once after all Composable functions have completed.

applyCoroutineContext

@InternalComposeApi
val applyCoroutineContextCoroutineContext

A Compose internal function. DO NOT call directly.

The coroutine context for the composition. This is used, for example, to implement LaunchedEffect. This context is managed by the Recomposer.

composition

val compositionControlledComposition

The composition that is used to control this composer.

compositionData

val compositionDataCompositionData

A tooling API function. DO NOT call directly.

The data stored for the composition. This is used by Compose tools, such as the preview and the inspector, to display or interpret the result of composition.

compoundKeyHash

@InternalComposeApi
val compoundKeyHashInt

A Compose internal property. DO NOT call directly. Use currentCompositeKeyHash instead.

This a hash value used to coordinate map externally stored state to the composition. For example, this is used by saved instance state to preserve state across activity lifetime boundaries.

This value is not likely to be unique but is not guaranteed unique. There are known cases, such as for loops without a key, where the runtime does not have enough information to make the compound key hash unique.

currentCompositionLocalMap

val currentCompositionLocalMapCompositionLocalMap

Returns the active set of CompositionLocals at the current position in the composition hierarchy. This is a lower level API that can be used to export and access CompositionLocal values outside of Composition.

This API does not track reads of CompositionLocals and does not automatically dispatch new values to previous readers when the value of a CompositionLocal changes. To use this API as intended, you must set up observation manually. This means:

  • For non-static CompositionLocals, composables reading this map need to observe the snapshot state for CompositionLocals being read to be notified when their values in this map change.

  • For static CompositionLocals, all composables including the composable reading this map will be recomposed and you will need to re-obtain this map to get the latest values.

Most applications shouldn't use this API directly, and should instead use CompositionLocal.current.

currentMarker

@ComposeCompilerApi
val currentMarkerInt

A Compose compiler plugin API. DO NOT call directly.

Return a marker for the current group that can be used in a call to endToMarker.

defaultsInvalid

@ComposeCompilerApi
val defaultsInvalidBoolean

A Compose compiler plugin API. DO NOT call directly.

Reflects whether the default parameter block of a Composable function is valid. This is false if a State object read in the startDefaults group was modified since the last time the Composable function was run.

inserting

@ComposeCompilerApi
val insertingBoolean

A Compose compiler plugin API. DO NOT call directly.

Reflects that a new part of the composition is being created, that is, the composition will insert new nodes into the resulting tree.

recomposeScope

@InternalComposeApi
val recomposeScopeRecomposeScope?

A Compose internal property. DO NOT call directly. Use currentRecomposeScope instead.

The invalidation current invalidation scope. An new invalidation scope is created whenever startRestartGroup is called. when this scope's RecomposeScope.invalidate is called then lambda supplied to endRestartGroup's ScopeUpdateScope will be scheduled to be run.

recomposeScopeIdentity

@ComposeCompilerApi
val recomposeScopeIdentityAny?

A Compose compiler plugin API. DO NOT call directly.

Return an object that can be used to uniquely identity of the current recomposition scope. This identity will be the same even if the recompose scope instance changes.

This is used internally by tooling track composable function invocations.

skipping

@ComposeCompilerApi
val skippingBoolean

A Compose compiler plugin API. DO NOT call directly.

Reflects whether the Composable function can skip. Even if a Composable function is called with the same parameters it might still need to run because, for example, a new value was provided for a CompositionLocal created by staticCompositionLocalOf.

Extension functions

materialize

fun Composer.materialize(modifier: Modifier): Modifier

Materialize any instance-specific composed modifiers for applying to a raw tree node. Call right before setting the returned modifier on an emitted node. You almost certainly do not need to call this function directly.

@ComposeCompilerApi
inline fun <T : Any?> Composer.cache(
    invalid: Boolean,
    block: @DisallowComposableCalls () -> T
): T

A Compose compiler plugin API. DO NOT call directly.

Cache, that is remember, a value in the composition data of a composition. This is used to implement remember and used by the compiler plugin to generate more efficient calls to remember when it determines these optimizations are safe.