---
title: "PausableComposition"
description: "A [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 [PausedComposition.isComplete] is `true` and
[PausedComposition.apply] has been called. The composition is incomplete and will not
automatically recompose until after [PausedComposition.apply] is called.

A [PausableComposition] is a [ReusableComposition] but [setPausableContent] should be used
instead of [ReusableComposition.setContentWithReuse] to create a paused composition.

If [Composition.setContent] or [ReusableComposition.setContentWithReuse] are used then the
composition behaves as if it wasn't pausable. If there is a [PausedComposition] that has not yet
been applied, an exception is thrown."
type: "interface"
---

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


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

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



```kotlin
public sealed interface PausableComposition : ReusableComposition
```


A `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 `PausedComposition.isComplete` is `true` and
`PausedComposition.apply` has been called. The composition is incomplete and will not
automatically recompose until after `PausedComposition.apply` is called.

A `PausableComposition` is a `ReusableComposition` but `setPausableContent` should be used
instead of `ReusableComposition.setContentWithReuse` to create a paused composition.

If `Composition.setContent` or `ReusableComposition.setContentWithReuse` are used then the
composition behaves as if it wasn't pausable. If there is a `PausedComposition` that has not yet
been applied, an exception is thrown.


## Functions

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


Set the content of the composition. A `PausedComposition` that is currently paused. No
composition is performed until `PausedComposition.resume` is called.
`PausedComposition.resume` should be called until `PausedComposition.isComplete` is `true`.
The composition should not be used until `PausedComposition.isComplete` is `true` and
`PausedComposition.apply` has been called.


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


Set the content of a reusable composition. A `PausedComposition` that is currently paused. No
composition is performed until `PausedComposition.resume` is called.
`PausedComposition.resume` should be called until `PausedComposition.isComplete` is `true`.
The composition should not be used until `PausedComposition.isComplete` is `true` and
`PausedComposition.apply` has been called.



