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

Recomposer

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

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

Summary

Public constructors
<init>(effectCoroutineContext: CoroutineContext)

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 completion of a shutDown operation.

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.

Unit

Permanently shut down this Recomposer for future use.

Companion functions
Recomposer

Retrieves Recomposer for the current thread.

Public constructors

<init>

Recomposer(effectCoroutineContext: CoroutineContext)

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

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.

join

suspend fun join(): Unit

Await the completion of a shutDown operation.

recomposeAndApplyChanges

suspend fun recomposeAndApplyChanges(frameCount: Long): Unit

Deprecated.

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 returns after recomposing frameCount times, or throws CancellationException if the Recomposer is shutDown or if the effectCoroutineContext used to construct the Recomposer is cancelled.

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.

shutDown

fun shutDown(): Unit

Permanently shut down this Recomposer for future use. All ongoing recompositions will stop, new composer invalidations with this Recomposer at the root will no longer occur, and any LaunchedEffects currently running in compositions managed by this Recomposer will be cancelled. Any rememberCoroutineScope scopes from compositions managed by this Recomposer will also be cancelled. See join to await the completion of all of these outstanding tasks.

Companion functions

current

@TestOnly fun current(): Recomposer

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