ReusableComposition

Interface

Common
public sealed interface ReusableComposition : Composition

A ReusableComposition is a Composition that can be reused for different composable content.

This interface is used by components that have to synchronize lifecycle of parent and child compositions and efficiently reuse the nodes emitted by ReusableComposeNode.

Functions

public fun setContentWithReuse(content: @Composable () -> Unit)

Update the composition with the content described by the content composable. After this has been called the changes to produce the initial composition has been calculated and applied to the composition.

This method forces this composition into "reusing" state before setting content. In reusing state, all remembered content is discarded, and nodes emitted by ReusableComposeNode are re-used for the new content. The nodes are only reused if the group structure containing the node matches new content.

Will throw an IllegalStateException if the composition has been disposed.

Parameters

contentA composable function that describes the content of the composition.
public fun deactivate()

Deactivate all observation scopes in composition and remove all remembered slots while preserving nodes in place. The composition can be re-activated by calling setContent with a new content.