---
title: "Recomposer"
description: "The scheduler for performing recomposition and applying updates to one or more [Composition]s."
type: "class"
---

<div class='type'>Class</div>


<a id='references'></a>

<div class='sourceset sourceset-common'>Common</div>


```kotlin
public class Recomposer(effectCoroutineContext: CoroutineContext) : CompositionContext()
```


The scheduler for performing recomposition and applying updates to one or more `Composition`s.


## Functions

```kotlin
public fun asRecomposerInfo(): RecomposerInfo
```


Obtain a read-only `RecomposerInfo` for this `Recomposer`.


```kotlin
public suspend fun runRecomposeAndApplyChanges(): Unit
```


Await the invalidation of any associated `Composer`s, recompose them, and apply their changes
to their associated `Composition`s if recomposition is successful.

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

This method will not return unless the `Recomposer` is `close`d and all effects in managed
compositions complete. Unhandled failure exceptions from child coroutines will be thrown by
this method.


```kotlin
public fun cancel()
```


Permanently shut down this `Recomposer` for future use. `currentState` will immediately
reflect `State.ShuttingDown` (or a lower state) before this call returns. All ongoing
recompositions will stop, new composer invalidations with this `Recomposer` at the root will
no longer occur, and any `LaunchedEffect`s 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.


```kotlin
public fun close()
```


Close this `Recomposer`. Once all effects launched by managed compositions complete, any
active call to `runRecomposeAndApplyChanges` will return normally and this `Recomposer` will
be `State.ShutDown`. See `join` to await the completion of all of these outstanding tasks.


```kotlin
public suspend fun join()
```


Await the completion of a `cancel` operation.


```kotlin
public suspend fun awaitIdle()
```


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.


```kotlin
public fun pauseCompositionFrameClock()
```


Pause broadcasting the frame clock while recomposing. This effectively pauses animations, or
any other use of the `withFrameNanos`, while the frame clock is paused.

`pauseCompositionFrameClock` should be called when the recomposer is not being displayed for
some reason such as not being the current activity in Android, for example.

Calls to `pauseCompositionFrameClock` are thread-safe and idempotent (calling it when the
frame clock is already paused is a no-op).


```kotlin
public fun resumeCompositionFrameClock()
```


Resume broadcasting the frame clock after is has been paused. Pending calls to
`withFrameNanos` will start receiving frame clock broadcasts at the beginning of the frame
and a frame will be requested if there are pending calls to `withFrameNanos` if a frame has
not already been scheduled.

Calls to `resumeCompositionFrameClock` are thread-safe and idempotent (calling it when the
frame clock is running is a no-op).


## Companion Object

#### Properties

<div class='sourceset sourceset-common'>Common</div>


```kotlin
public val runningRecomposers: StateFlow<Set<RecomposerInfo>>
```


An observable `Set` of `RecomposerInfo`s for currently
`running` `Recomposer`s. Emitted sets are immutable.





