Class

CompositionContext

A CompositionContext is an opaque type that is used to logically "link" two compositions together.

Source set: Common
public abstract class CompositionContext internal constructor()

A CompositionContext is an opaque type that is used to logically "link" two compositions together. The CompositionContext instance represents a reference to the "parent" composition in a specific position of that composition's tree, and the instance can then be given to a new "child" composition. This reference ensures that invalidations and CompositionLocals flow logically through the two compositions as if they were not separate.

The "parent" of a root composition is a Recomposer.

Properties

effectCoroutineContext

Source set: Common
public abstract val effectCoroutineContext: CoroutineContext

The CoroutineContext with which effects for the composition will be executed in.

Functions

scheduleFrameEndCallback

Source set: Common
public abstract fun scheduleFrameEndCallback(action: () -> Unit): CancellationHandle

Schedules action to run when the Recomposer finishes the next composition frame.

The frame includes all subcompositions. See Composer.scheduleFrameEndCallback for the timing rules. action always runs on the applier thread.

Return

A CancellationHandle that removes action from the queue. The handle is thread-safe. It does not stop an action that is already running.

Throws: kotlin.coroutines.cancellation.CancellationException

if the Recomposer that owns the associated composition is shutting down or has shut down.

Jetpack Compose beyond MaterialFree components, screens and templates for apps that don’t look like Google’s. Copy them into your app, or let your coding agent add them.Browse for free

Content updated: