Android 12 Developer Preview is here! Try it out, and give us your feedback!

Composition

interface Composition
androidx.compose.runtime.Composition

A composition object is usually constructed for you, and returned from an API that is used to initially compose a UI. For instance, setContent returns a Composition.

The dispose method should be used when you would like to dispose of the UI and the Composition.

Summary

Public methods
abstract Unit

Clear the hierarchy that was created from the composition.

abstract Unit
setContent(content: () -> Unit)

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

Properties
abstract Boolean

Returns true if any pending invalidations have been scheduled.

abstract Boolean

True if dispose has been called.

Public methods

dispose

abstract fun dispose(): Unit

Clear the hierarchy that was created from the composition.

setContent

abstract fun setContent(content: () -> Unit): 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.

Will throw an IllegalStateException if the composition has been disposed.

Parameters
content: () -> Unit A composable function that describes the tree.
Exceptions
IllegalStateException thrown in the composition has been disposed.

Properties

hasInvalidations

abstract val hasInvalidations: Boolean

Returns true if any pending invalidations have been scheduled.

isDisposed

abstract val isDisposed: Boolean

True if dispose has been called.