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

Recomposer

class Recomposer
kotlin.Any
   ↳ androidx.compose.runtime.Recomposer

The scheduler for performing recomposition and applying updates to one or more Compositions. frameClock is used to align changes with display frames.

Summary

Public constructors
<init>(embeddingContext: EmbeddingContext = EmbeddingContext())

The scheduler for performing recomposition and applying updates to one or more Compositions.

Public methods
suspend Unit

Suspends until the currently pending recomposition frame is complete.

Boolean

Returns true if any pending invalidations have been scheduled.

suspend Unit

Await the invalidation of any associated Composers, recompose them, and apply their changes to their associated Compositions if recomposition is successful.

suspend Nothing

Await the invalidation of any associated Composers, recompose them, and apply their changes to their associated Compositions if recomposition is successful.

Companion functions
Recomposer

Retrieves Recomposer for the current thread.

Properties
EmbeddingContext

MonotonicFrameClock

Public constructors

<init>

Recomposer(embeddingContext: EmbeddingContext = EmbeddingContext())

The scheduler for performing recomposition and applying updates to one or more Compositions. frameClock is used to align changes with display frames.

Public methods

awaitIdle

suspend fun awaitIdle(): Unit

Suspends until the currently pending recomposition frame is complete. Any recomposition for this recomposer triggered by actions before this call begins will be complete and applied (if recomposition was successful) when this call returns.

If runRecomposeAndApplyChanges is not currently running the Recomposer is considered idle and this method will not suspend.

hasInvalidations

fun hasInvalidations(): Boolean

Returns true if any pending invalidations have been scheduled.

recomposeAndApplyChanges

suspend fun recomposeAndApplyChanges(frameCount: Long): Unit

Await the invalidation of any associated Composers, recompose them, and apply their changes to their associated Compositions if recomposition is successful. Any launched effects of composition will be launched into the receiver CoroutineScope.

While runRecomposeAndApplyChanges is running, awaitIdle will suspend until there are no more invalid composers awaiting recomposition.

This method returns after recomposing frameCount times.

runRecomposeAndApplyChanges

suspend fun runRecomposeAndApplyChanges(): Nothing

Await the invalidation of any associated Composers, recompose them, and apply their changes to their associated Compositions if recomposition is successful.

While runRecomposeAndApplyChanges is running, awaitIdle will suspend until there are no more invalid composers awaiting recomposition.

This method never returns. Cancel the calling CoroutineScope to stop.

Properties

embeddingContext

var embeddingContext: EmbeddingContext

frameClock

val frameClock: MonotonicFrameClock

Companion functions

current

@TestOnly fun current(): Recomposer

Retrieves Recomposer for the current thread. Needs to be the main thread.