Composition
-
Cmn
interface Composition
ControlledComposition |
A controlled composition is a |
ReusableComposition |
A |
PausableComposition |
A |
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 functions |
||
|---|---|---|
Unit |
dispose()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 |
Cmn
|
Public properties |
||
|---|---|---|
Boolean |
Returns true if any pending invalidations have been scheduled. |
Cmn
|
Boolean |
True if |
Cmn
|
Extension functions |
||
|---|---|---|
CompositionObserverHandle? |
Observe the composition. |
Cmn
|
Public functions
dispose
fun dispose(): Unit
Clear the hierarchy that was created from the composition and release resources allocated for composition. After calling dispose the composition will no longer be recomposed and calling setContent will throw an IllegalStateException. Calling dispose is idempotent, all calls after the first are a no-op.
setContent
fun setContent(content: @Composable () -> 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: @Composable () -> Unit |
A composable function that describes the content of the composition. |
| Throws | |
|---|---|
kotlin.IllegalStateException |
thrown in the composition has been |
Public properties
hasInvalidations
val hasInvalidations: Boolean
Returns true if any pending invalidations have been scheduled. An invalidation is schedule if RecomposeScope.invalidate has been called on any composition scopes create for the composition.
Modifying MutableState.value of a value produced by mutableStateOf will automatically call RecomposeScope.invalidate for any scope that read State.value of the mutable state instance during composition.
| See also | |
|---|---|
RecomposeScope |
|
mutableStateOf |
Extension functions
setObserver
@ExperimentalComposeRuntimeApi
fun Composition.setObserver(observer: CompositionObserver): CompositionObserverHandle?
Observe the composition. Calling this twice on the same composition will implicitly dispose the previous observer. the CompositionObserver will be called for this composition and all sub-composition, transitively, for which this composition is a context. If setObserver is called on a sub-composition, it will override the parent composition observer for itself and all its sub-compositions.
| Parameters | |
|---|---|
observer: CompositionObserver |
the observer that will be informed of composition events for this composition and all sub-compositions for which this composition is the composition context. Observing a composition will prevent the parent composition's observer from receiving composition events about this composition. |
| Returns | |
|---|---|
CompositionObserverHandle? |
a handle that allows the observer to be disposed and detached from the composition. Disposing an observer for a composition with a parent observer will begin sending the events to the parent composition's observer. A |