CompositionContext

Known direct subclasses
Recomposer

The scheduler for performing recomposition and applying updates to one or more Compositions.


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.

Summary

Public functions

abstract CancellationHandle

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

Cmn

Public properties

abstract CoroutineContext

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

Cmn

Public functions

scheduleFrameEndCallback

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.

Returns
CancellationHandle

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.

Public properties

effectCoroutineContext

abstract val effectCoroutineContext: CoroutineContext

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