# PausedComposition

Artifact: [androidx.compose.runtime:runtime](https://developer.android.com/jetpack/androidx/releases/compose-runtime) [View Source](https://cs.android.com/search?q=file:androidx/compose/runtime/PausableComposition.kt+class:androidx.compose.runtime.PausedComposition) Added in [1.8.0](https://developer.android.com/jetpack/androidx/releases/compose-runtime#1.8.0) Common/AllAndroid/JVMNative/C/iOSJavaScript
- Cmn

  ```
  sealed interface PausedComposition
  ```

*** ** * ** ***

`https://developer.android.com/reference/kotlin/androidx/compose/runtime/PausedComposition` is the result of calling `https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composition#setContent(kotlin.Function0)` or `https://developer.android.com/reference/kotlin/androidx/compose/runtime/ReusableComposition#setContentWithReuse(kotlin.Function0)`. It is used to drive the paused composition to completion. A `https://developer.android.com/reference/kotlin/androidx/compose/runtime/PausedComposition` should not be used until `https://developer.android.com/reference/kotlin/androidx/compose/runtime/PausedComposition#isComplete()` is `true` and `https://developer.android.com/reference/kotlin/androidx/compose/runtime/PausedComposition#apply()` has been called.

A `https://developer.android.com/reference/kotlin/androidx/compose/runtime/PausedComposition` is created paused and will only compose the `content` parameter when `https://developer.android.com/reference/kotlin/androidx/compose/runtime/PausedComposition#resume(androidx.compose.runtime.ShouldPauseCallback)` is called the first time.

## Summary

| ### Public functions |
|---|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/runtime/PausedComposition#apply()()` Apply the composition. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/runtime/PausedComposition#cancel()()` Cancels the paused composition. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/runtime/PausedComposition#resume(androidx.compose.runtime.ShouldPauseCallback)(shouldPause: https://developer.android.com/reference/kotlin/androidx/compose/runtime/ShouldPauseCallback)` Resume the composition that has been paused. | Cmn |

| ### Public properties |
|---|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/runtime/PausedComposition#isApplied()` Returns `true` when the `https://developer.android.com/reference/kotlin/androidx/compose/runtime/PausedComposition` is applied. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/runtime/PausedComposition#isCancelled()` Returns `true` when the `https://developer.android.com/reference/kotlin/androidx/compose/runtime/PausedComposition` is cancelled. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/runtime/PausedComposition#isComplete()` Returns `true` when the `https://developer.android.com/reference/kotlin/androidx/compose/runtime/PausedComposition` is complete. | Cmn |

## Public functions

### apply

Cmn Added in [1.8.0](https://developer.android.com/jetpack/androidx/releases/compose-runtime#1.8.0)

```
fun apply(): Unit
```

Apply the composition. This is the last step of a paused composition and is required to be called prior to the composition is usable.

Calling `https://developer.android.com/reference/kotlin/androidx/compose/runtime/PausedComposition#apply()` should always be proceeded with a check of `https://developer.android.com/reference/kotlin/androidx/compose/runtime/PausedComposition#isComplete()` before it is called and potentially calling `https://developer.android.com/reference/kotlin/androidx/compose/runtime/PausedComposition#resume(androidx.compose.runtime.ShouldPauseCallback)` in a loop until `https://developer.android.com/reference/kotlin/androidx/compose/runtime/PausedComposition#isComplete()` returns `true`. This can happen if `https://developer.android.com/reference/kotlin/androidx/compose/runtime/PausedComposition#resume(androidx.compose.runtime.ShouldPauseCallback)` returned `true` but `https://developer.android.com/reference/kotlin/androidx/compose/runtime/PausedComposition#apply()` was not synchronously called immediately afterwords. Any state that was read that changed between when `https://developer.android.com/reference/kotlin/androidx/compose/runtime/PausedComposition#resume(androidx.compose.runtime.ShouldPauseCallback)` being called and `https://developer.android.com/reference/kotlin/androidx/compose/runtime/PausedComposition#apply()` being called may require the paused composition to be resumed before applied.

### cancel

Cmn Added in [1.8.0](https://developer.android.com/jetpack/androidx/releases/compose-runtime#1.8.0)

```
fun cancel(): Unit
```

Cancels the paused composition. This should only be used if the composition is going to be disposed and the entire composition is not going to be used.

### resume

Cmn Added in [1.8.0](https://developer.android.com/jetpack/androidx/releases/compose-runtime#1.8.0)

```
fun resume(shouldPause: ShouldPauseCallback): Boolean
```

Resume the composition that has been paused. This method should be called until `https://developer.android.com/reference/kotlin/androidx/compose/runtime/PausedComposition#resume(androidx.compose.runtime.ShouldPauseCallback)` returns `true` or `https://developer.android.com/reference/kotlin/androidx/compose/runtime/PausedComposition#isComplete()` is `true` which has the same result as the last result of calling `https://developer.android.com/reference/kotlin/androidx/compose/runtime/PausedComposition#resume(androidx.compose.runtime.ShouldPauseCallback)`. The `https://developer.android.com/reference/kotlin/androidx/compose/runtime/PausedComposition#resume(androidx.compose.runtime.ShouldPauseCallback)` parameter is a lambda that returns whether the composition should be paused. For example, in lazy lists this returns `false` until just prior to the next frame starting in which it returns `true`

Calling `https://developer.android.com/reference/kotlin/androidx/compose/runtime/PausedComposition#resume(androidx.compose.runtime.ShouldPauseCallback)` after it returns `true` or when `https://developer.android.com/reference/kotlin/androidx/compose/runtime/PausedComposition#isComplete()` is `true` will throw an exception.

| Parameters |
|---|---|
| `shouldPause: https://developer.android.com/reference/kotlin/androidx/compose/runtime/ShouldPauseCallback` | A lambda that is used to determine if the composition should be paused. This lambda is called often so should be a very simple calculation. Returning `true` does not guarantee the composition will pause, it should only be considered a request to pause the composition. Not all composable functions are pausable and only pausable composition functions will pause. |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `true` if the composition is complete and `false` if one or more calls to `resume` are required to complete composition. |

## Public properties

### isApplied

Cmn Added in [1.9.0](https://developer.android.com/jetpack/androidx/releases/compose-runtime#1.9.0)

```
val isApplied: Boolean
```

Returns `true` when the `https://developer.android.com/reference/kotlin/androidx/compose/runtime/PausedComposition` is applied. `https://developer.android.com/reference/kotlin/androidx/compose/runtime/PausedComposition#isApplied()` becomes `true` after calling `https://developer.android.com/reference/kotlin/androidx/compose/runtime/PausedComposition#apply()`. Calling any method on the `https://developer.android.com/reference/kotlin/androidx/compose/runtime/PausedComposition` when `https://developer.android.com/reference/kotlin/androidx/compose/runtime/PausedComposition#isApplied()` is `true` will throw an exception.

### isCancelled

Cmn Added in [1.9.0](https://developer.android.com/jetpack/androidx/releases/compose-runtime#1.9.0)

```
val isCancelled: Boolean
```

Returns `true` when the `https://developer.android.com/reference/kotlin/androidx/compose/runtime/PausedComposition` is cancelled. `https://developer.android.com/reference/kotlin/androidx/compose/runtime/PausedComposition#isCancelled()` becomes `true` after calling `https://developer.android.com/reference/kotlin/androidx/compose/runtime/PausedComposition#cancel()`. Calling any method on the `https://developer.android.com/reference/kotlin/androidx/compose/runtime/PausedComposition` when `https://developer.android.com/reference/kotlin/androidx/compose/runtime/PausedComposition#isCancelled()` is `true` will throw an exception. If `https://developer.android.com/reference/kotlin/androidx/compose/runtime/PausedComposition#isCancelled()` is `true` then the `https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composition` that was used to create `https://developer.android.com/reference/kotlin/androidx/compose/runtime/PausedComposition` is in an uncertain state and must be discarded.

### isComplete

Cmn Added in [1.8.0](https://developer.android.com/jetpack/androidx/releases/compose-runtime#1.8.0)

```
val isComplete: Boolean
```

Returns `true` when the `https://developer.android.com/reference/kotlin/androidx/compose/runtime/PausedComposition` is complete. `https://developer.android.com/reference/kotlin/androidx/compose/runtime/PausedComposition#isComplete()` matches the last value returned from `https://developer.android.com/reference/kotlin/androidx/compose/runtime/PausedComposition#resume(androidx.compose.runtime.ShouldPauseCallback)`. Once a `https://developer.android.com/reference/kotlin/androidx/compose/runtime/PausedComposition` is `https://developer.android.com/reference/kotlin/androidx/compose/runtime/PausedComposition#isComplete()` the `https://developer.android.com/reference/kotlin/androidx/compose/runtime/PausedComposition#apply()` method should be called. If the `https://developer.android.com/reference/kotlin/androidx/compose/runtime/PausedComposition#apply()` method is not called synchronously and immediately after `https://developer.android.com/reference/kotlin/androidx/compose/runtime/PausedComposition#resume(androidx.compose.runtime.ShouldPauseCallback)` returns `true` then this `https://developer.android.com/reference/kotlin/androidx/compose/runtime/PausedComposition#isComplete()` can return `false` as any state changes read by the paused composition while it is paused will cause the composition to require the paused composition to need to be resumed before it is used.