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

Recomposer

class Recomposer
kotlin.Any
   ↳ androidx.compose.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

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

suspend Unit
recomposeAndApplyChanges(applyCoroutineScope: CoroutineScope, frameClock: CompositionFrameClock, frameCount: Long)

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.

Boolean

Check if there's pending changes to be recomposed in this thread

Properties
CompositionFrameClock

Public constructors

<init>

Recomposer()

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.

hasPendingChanges

fun hasPendingChanges(): Boolean

recomposeAndApplyChanges

suspend fun recomposeAndApplyChanges(
    applyCoroutineScope: CoroutineScope,
    frameClock: CompositionFrameClock,
    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(frameClock: CompositionFrameClock): 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

frameClock

val frameClock: CompositionFrameClock

Companion functions

current

@TestOnly fun current(): Recomposer

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

hasPendingChanges

fun hasPendingChanges(): Boolean

Deprecated.

Check if there's pending changes to be recomposed in this thread

Return
true if there 're pending changes in this thread, false otherwise