PausableComposition


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.

Summary

Public functions

PausedComposition

Set the content of the composition.

Cmn
PausedComposition

Set the content of a resuable composition.

Cmn

Inherited functions

From androidx.compose.runtime.Composition
Unit

Clear the hierarchy that was created from the composition and release resources allocated for composition.

Cmn
Unit
setContent(content: @Composable () -> Unit)

Update the composition with the content described by the content composable.

Cmn
From androidx.compose.runtime.ReusableComposition
Unit

Deactivate all observation scopes in composition and remove all remembered slots while preserving nodes in place.

Cmn
Unit

Update the composition with the content described by the content composable.

Cmn

Inherited properties

From androidx.compose.runtime.Composition
Boolean

Returns true if any pending invalidations have been scheduled.

Cmn
Boolean

True if dispose has been called.

Cmn

Public functions

setPausableContent

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.

setPausableContentWithReuse

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

Set the content of a resuable 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.