androidx.compose.runtime.tooling

Interfaces

CompositionData

A CompositionData is the data tracked by the composer during composition.

Cmn
CompositionErrorContext

Provides a way to attach a compose stack trace to a throwable based on a location of compose node in composition.

Cmn
CompositionGroup

CompositionGroup is a group of data slots tracked independently by composition.

Cmn
CompositionInstance

CompositionInstance provides information about the composition of which a CompositionData is part.

Cmn
CompositionObserver

Observe RecomposeScope management inside composition.

Cmn
CompositionObserverHandle

The handle returned by Composition.setObserver and Recomposer.observe.

Cmn
CompositionRegistrationObserver

Observe when new compositions are added to a recomposer.

Cmn
ObservableComposition

A composition instance that supports observing lifecycle of its RecomposeScope.

Cmn

Extension functions summary

CompositionInstance?

Find the CompositionInstance associated with the root CompositionData.

Cmn
CompositionObserverHandle

Register an observer to be notified when a composition is added to or removed from the given Recomposer.

Cmn
CompositionObserverHandle?

Observe the composition.

Cmn

Top-level properties summary

CompositionLocal<CompositionErrorContext?>

Used to attach a compose stack trace to a throwable based on a location of compose node in composition.

Cmn
ProvidableCompositionLocal<MutableSet<CompositionData>?>

A set of slot tables that where produced when in inspection mode.

Cmn

Extension functions

findCompositionInstance

fun CompositionData.findCompositionInstance(): CompositionInstance?

Find the CompositionInstance associated with the root CompositionData. This is only valid for instances of CompositionData that are recorded in a LocalInspectionTables table directly.

Even though CompositionGroups implement the CompositionData interface, only the root CompositionData has an associated CompositionInstance. All CompositionGroup instances will return null.

observe

@ExperimentalComposeRuntimeApi
fun Recomposer.observe(observer: CompositionRegistrationObserver): CompositionObserverHandle

Register an observer to be notified when a composition is added to or removed from the given Recomposer. When this method is called, the observer will be notified of all currently registered compositions per the documentation in CompositionRegistrationObserver.onCompositionRegistered.

Parameters
observer: CompositionRegistrationObserver

the observer that will be informed of new compositions registered with this Recomposer.

Returns
CompositionObserverHandle

a handle that allows the observer to be disposed and detached from the Recomposer.

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 null indicates the composition does not support being observed.

Top-level properties

LocalCompositionErrorContext

val LocalCompositionErrorContextCompositionLocal<CompositionErrorContext?>

Used to attach a compose stack trace to a throwable based on a location of compose node in composition. This context is expected to be used by custom node implementations to attach diagnostic compose stack traces to exceptions in passes that are not handled by the Compose runtime (example: measure / layout / draw in Compose UI).

Compose runtime automatically appends information about exceptions that happen in composition and effects.

LocalInspectionTables

val LocalInspectionTablesProvidableCompositionLocal<MutableSet<CompositionData>?>

A set of slot tables that where produced when in inspection mode.