# PausableComposition

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.PausableComposition) 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 PausableComposition : ReusableComposition
  ```

*** ** * ** ***

A `https://developer.android.com/reference/kotlin/androidx/compose/runtime/PausableComposition` is a sub-composition that can be composed incrementally as it supports being paused and resumed.

Pausable sub-composition can be used between frames to prepare a sub-composition before it is required by the main composition. For example, this is used in lazy lists to prepare list items in between frames to that are likely to be scrolled in. The composition is paused when the start of the next frame is near allowing composition to be spread across multiple frames without delaying the production of the next frame.

The result of the composition should not be used (e.g. the nodes should not added to a layout tree or placed in layout) 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. The composition is incomplete and will not automatically recompose until after `https://developer.android.com/reference/kotlin/androidx/compose/runtime/PausedComposition#apply()` is called.

A `https://developer.android.com/reference/kotlin/androidx/compose/runtime/PausableComposition` is a `https://developer.android.com/reference/kotlin/androidx/compose/runtime/ReusableComposition` but `https://developer.android.com/reference/kotlin/androidx/compose/runtime/PausableComposition#setPausableContent(kotlin.Function0)` should be used instead of `https://developer.android.com/reference/kotlin/androidx/compose/runtime/ReusableComposition#setContentWithReuse(kotlin.Function0)` to create a paused composition.

If `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)` are used then the composition behaves as if it wasn't pausable. If there is a `https://developer.android.com/reference/kotlin/androidx/compose/runtime/PausedComposition` that has not yet been applied, an exception is thrown.

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composition` |   |
| `https://developer.android.com/reference/kotlin/androidx/compose/runtime/ReusableComposition` |   |

## Summary

| ### Public functions |
|---|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/runtime/PausedComposition` | `https://developer.android.com/reference/kotlin/androidx/compose/runtime/PausableComposition#setPausableContent(kotlin.Function0)(content: @https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composable () -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)` Set the content of the composition. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/runtime/PausedComposition` | `https://developer.android.com/reference/kotlin/androidx/compose/runtime/PausableComposition#setPausableContentWithReuse(kotlin.Function0)(content: @https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composable () -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)` Set the content of a reusable composition. | Cmn |

| ### Inherited functions |
|---|
| From [androidx.compose.runtime.Composition](https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composition) |---|---|---| | `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composition#dispose()()` Clear the hierarchy that was created from the composition and release resources allocated for composition. | Cmn | | `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composition#setContent(kotlin.Function0)(content: @https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composable () -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)` Update the composition with the content described by the `https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composition#setContent(kotlin.Function0)` composable. | Cmn | |
| From [androidx.compose.runtime.ReusableComposition](https://developer.android.com/reference/kotlin/androidx/compose/runtime/ReusableComposition) |---|---|---| | `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/runtime/ReusableComposition#deactivate()()` Deactivate all observation scopes in composition and remove all remembered slots while preserving nodes in place. | Cmn | | `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/runtime/ReusableComposition#setContentWithReuse(kotlin.Function0)(content: @https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composable () -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)` Update the composition with the content described by the `https://developer.android.com/reference/kotlin/androidx/compose/runtime/ReusableComposition#setContentWithReuse(kotlin.Function0)` composable. | Cmn | |

| ### Inherited properties |
|---|
| From [androidx.compose.runtime.Composition](https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composition) |---|---|---| | `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composition#hasInvalidations()` Returns true if any pending invalidations have been scheduled. | Cmn | | `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composition#isDisposed()` True if `https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composition#dispose()` has been called. | Cmn | |

## Public functions

### setPausableContent

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

```
fun setPausableContent(content: @Composable () -> Unit): PausedComposition
```

Set the content of the composition. A `https://developer.android.com/reference/kotlin/androidx/compose/runtime/PausedComposition` that is currently paused. No composition is performed until `https://developer.android.com/reference/kotlin/androidx/compose/runtime/PausedComposition#resume(androidx.compose.runtime.ShouldPauseCallback)` is called. `https://developer.android.com/reference/kotlin/androidx/compose/runtime/PausedComposition#resume(androidx.compose.runtime.ShouldPauseCallback)` should be called until `https://developer.android.com/reference/kotlin/androidx/compose/runtime/PausedComposition#isComplete()` is `true`. The composition 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.

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composition#setContent(kotlin.Function0)` |   |
| `https://developer.android.com/reference/kotlin/androidx/compose/runtime/ReusableComposition#setContentWithReuse(kotlin.Function0)` |   |

### setPausableContentWithReuse

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

```
fun setPausableContentWithReuse(content: @Composable () -> Unit): PausedComposition
```

Set the content of a reusable composition. A `https://developer.android.com/reference/kotlin/androidx/compose/runtime/PausedComposition` that is currently paused. No composition is performed until `https://developer.android.com/reference/kotlin/androidx/compose/runtime/PausedComposition#resume(androidx.compose.runtime.ShouldPauseCallback)` is called. `https://developer.android.com/reference/kotlin/androidx/compose/runtime/PausedComposition#resume(androidx.compose.runtime.ShouldPauseCallback)` should be called until `https://developer.android.com/reference/kotlin/androidx/compose/runtime/PausedComposition#isComplete()` is `true`. The composition 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.

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composition#setContent(kotlin.Function0)` |   |
| `https://developer.android.com/reference/kotlin/androidx/compose/runtime/ReusableComposition#setContentWithReuse(kotlin.Function0)` |   |