Package androidx.compose.runtime

Types

AbstractApplier
Link copied to clipboard
common
abstract class AbstractApplier<T>(root: T) : Applier<T>
An abstract Applier implementation.
Ambient
Link copied to clipboard
common
sealed class Ambient<T>
Compose passes data through the composition tree explicitly through means of parameters to composable functions.
Applier
Link copied to clipboard
common
interface Applier<N>
An Applier is responsible for applying the tree-based operations that get emitted during a composition.
AtomicReference
Link copied to clipboard
class AtomicReference<V>(value: V)
typealias AtomicReference = AtomicReference<V>
typealias AtomicReference = AtomicReference<V>
CheckResult
Link copied to clipboard
annotation class CheckResult(suggest: String)
annotation class CheckResult(suggest: String)
CommitScope
Link copied to clipboard
common
interface CommitScope
A CommitScope represents an object that executes some code and has a cleanup in the context of the Composition lifecycle.
Composable
Link copied to clipboard
common
Composable functions are the fundamental building blocks of an application built with Compose.
ComposableContract
Link copied to clipboard
common
annotation class ComposableContract(restartable: Boolean, readonly: Boolean, tracked: Boolean, preventCapture: Boolean)
This annotation can be applied to Composable functions and provide metadata to the compiler that imply compose-specific contracts that the author of the function is guaranteeing the function complies with.
ComposeCompilerApi
Link copied to clipboard
common
Composer
Link copied to clipboard
common
class Composer<N>(applier: Applier<N>, parentReference: CompositionReference)
Implementation of a composer for mutable tree.
Composition
Link copied to clipboard
common
interface Composition
A composition object is usually constructed for you, and returned from an API that is used to initially compose a UI.
CompositionData
Link copied to clipboard
common
interface CompositionData
A CompositionData is the data tracked by the composer during composition.
CompositionGroup
Link copied to clipboard
common
interface CompositionGroup : CompositionData
CompositionGroup is a group of data slots tracked independently by composition.
CompositionLifecycleObserver
Link copied to clipboard
common
interface CompositionLifecycleObserver
Objects implementing this interface are notified when they are initially used in a composition and when they are no longer being used.
CompositionReference
Link copied to clipboard
common
abstract class CompositionReference
A CompositionReference is an opaque type that is used to logically "link" two compositions together.
DisposableEffectDisposable
Link copied to clipboard
common
interface DisposableEffectDisposable
DisposableEffectScope
Link copied to clipboard
common
class DisposableEffectScope
Receiver scope for DisposableEffect that offers the onDispose clause that should be the last statement in any call to DisposableEffect.
EmbeddingContext
Link copied to clipboard
common
interface EmbeddingContext
ExperimentalComposeApi
Link copied to clipboard
common
annotation class ExperimentalComposeApi
FrameManager
Link copied to clipboard
common
object FrameManager
The frame manager manages how changes to state objects are observed.
Immutable
Link copied to clipboard
common
annotation class Immutable
Immutable can be used to mark class as producing immutable instances.
InternalComposeApi
Link copied to clipboard
common
annotation class InternalComposeApi
KeyInfo
Link copied to clipboard
common
class KeyInfo
Information about groups and their keys.
MainThread
Link copied to clipboard
annotation class MainThread
annotation class MainThread
MutableState
Link copied to clipboard
common
interface MutableState<T> : State<T>
A mutable value holder where reads to the value property during the execution of a Composable function, the current RecomposeScope will be subscribed to changes of that value.
NoLiveLiterals
Link copied to clipboard
common
This annotation is used to indicate to the Compose Compiler to not attempt to generate live literals inside the scope of the declaration it is applied to, even when the live literals code generation is turned on.
ProduceStateScope
Link copied to clipboard
common
interface ProduceStateScope<T> : MutableState<T> , CoroutineScope
Receiver scope for use with produceState.
ProvidableAmbient
Link copied to clipboard
common
abstract class ProvidableAmbient<T> : Ambient<T>
A ProvidableAmbient can be used in Providers to provide values.
ProvidedValue
Link copied to clipboard
common
class ProvidedValue<T>
An instance to hold a value provided by Providers and is created by the ProvidableAmbient.provides infixed operator.
Recomposer
Link copied to clipboard
common
class Recomposer(effectCoroutineContext: CoroutineContext) : CompositionReference
The scheduler for performing recomposition and applying updates to one or more Compositions.
ScopeUpdateScope
Link copied to clipboard
common
interface ScopeUpdateScope
Internal compose compiler plugin API that is used to update the function the composer will call to recompose a recomposition scope.
SkippableUpdater
Link copied to clipboard
common
class SkippableUpdater<T>
SnapshotMutationPolicy
Link copied to clipboard
common
interface SnapshotMutationPolicy<T>
A policy to control how the result of mutableStateOf report and merge changes to the state object.
Stable
Link copied to clipboard
common
Stable is used to communicate some guarantees to the compose compiler about how a certain type or function will behave.
StableMarker
Link copied to clipboard
common
annotation class StableMarker
StableMarker marks an annotation as indicating a type is stable.
State
Link copied to clipboard
common
interface State<T>
A value holder where reads to the value property during the execution of a Composable function, the current RecomposeScope will be subscribed to changes of that value.
TestOnly
Link copied to clipboard
UnionType
Link copied to clipboard
common
annotation class UnionType(types: KClass<*>)
Updater
Link copied to clipboard
common
class Updater<T>
WeakHashMap
Link copied to clipboard
common
class WeakHashMap<K, V> : MutableMap<K, V>

Functions

ambientOf
Link copied to clipboard
common
fun <T> ambientOf(policy: SnapshotMutationPolicy<T> = @OptIn(ExperimentalComposeApi::class) structuralEqualityPolicy(), defaultFactory: () -> T? = null): ProvidableAmbient<T>
Create an ambient key that can be provided using Providers.
clearRoots
Link copied to clipboard
common
fun clearRoots()
collectAsState
Link copied to clipboard
common
@ExperimentalCoroutinesApi()
inline fun <T> StateFlow<T>.collectAsState(context: CoroutineContext = EmptyCoroutineContext): State<T>
Collects values from this StateFlow and represents its latest value via State.
inline fun <T : R, R> Flow<T>.collectAsState(initial: R, context: CoroutineContext = EmptyCoroutineContext): State<R>
Collects values from this Flow and represents its latest value via State.
compositionFor
Link copied to clipboard
common
fun compositionFor(key: Any, applier: Applier<*>, parent: CompositionReference, onCreated: () -> Unit = {}): Composition
This method is the way to initiate a composition.
compositionReference
Link copied to clipboard
common
fun compositionReference(): CompositionReference
An Effect to construct a CompositionReference at the current point of composition.
derivedStateOf
Link copied to clipboard
common
fun <T> derivedStateOf(calculation: () -> T): State<T>
Creates a State object whose State.value is the result of calculation.
DisposableEffect
Link copied to clipboard
common
@ComposableContract(restartable = false)
fun DisposableEffect(effect: DisposableEffectScope.() -> DisposableEffectDisposable)
@ComposableContract(restartable = false)
fun DisposableEffect(subject: Any?, effect: DisposableEffectScope.() -> DisposableEffectDisposable)
A side effect of composition that must run for any new unique value of subject and must be reversed or cleaned up if subject changes or if the DisposableEffect leaves the composition.
@ComposableContract(restartable = false)
fun DisposableEffect(vararg subjects: Any?, effect: DisposableEffectScope.() -> DisposableEffectDisposable)
A side effect of composition that must run for any new unique value of subjects and must be reversed or cleaned up if any subjects change or if the DisposableEffect leaves the composition.
@ComposableContract(restartable = false)
fun DisposableEffect(subject1: Any?, subject2: Any?, effect: DisposableEffectScope.() -> DisposableEffectDisposable)
A side effect of composition that must run for any new unique value of subject1 or subject2 and must be reversed or cleaned up if subject1 or subject2 changes, or if the DisposableEffect leaves the composition.
@ComposableContract(restartable = false)
fun DisposableEffect(subject1: Any?, subject2: Any?, subject3: Any?, effect: DisposableEffectScope.() -> DisposableEffectDisposable)
A side effect of composition that must run for any new unique value of subject1, subject2 or subject3 and must be reversed or cleaned up if subject1, subject2 or subject3 changes, or if the DisposableEffect leaves the composition.
EmbeddingContext
Link copied to clipboard
common
fun EmbeddingContext(): EmbeddingContext
emit
Link copied to clipboard
common
inline fun <T : Any, E : Applier<*>> emit(noinline ctor: () -> T, update: Updater<T>.() -> Unit)
Emits a node into the composition of type T.
inline fun <T, E : Applier<*>> emit(noinline ctor: () -> T, update: Updater<T>.() -> Unit, content: () -> Unit)
Emits a node into the composition of type T.
@ComposableContract(readonly = true)
inline fun <T, E : Applier<*>> emit(noinline ctor: () -> T, update: Updater<T>.() -> Unit, noinline skippableUpdate: SkippableUpdater<T>.() -> Unit, content: () -> Unit)
Emits a node into the composition of type T.
emptyContent
Link copied to clipboard
common
fun emptyContent(): () -> Unit
Represents empty content for a Composable function.
getValue
Link copied to clipboard
common
inline operator fun <T> State<T>.getValue(thisObj: Any?, property: KProperty<*>): T
Permits property delegation of vals using by for State.
isJoinedKey
Link copied to clipboard
common
fun isJoinedKey(key: Any?): Boolean
joinedKeyLeft
Link copied to clipboard
common
fun joinedKeyLeft(key: Any?): Any?
joinedKeyRight
Link copied to clipboard
common
fun joinedKeyRight(key: Any?): Any?
key
Link copied to clipboard
common
inline fun <T> key(vararg inputs: Any?, block: () -> T): T
key is a utility composable that is used to "group" or "key" a block of execution inside of a composition.
keySourceInfoOf
Link copied to clipboard
common
fun keySourceInfoOf(key: Any): String?
LaunchedEffect
Link copied to clipboard
common
fun LaunchedEffect(block: suspend CoroutineScope.() -> Unit)
When LaunchedEffect enters the composition it will launch block into the composition's CoroutineContext.
@ComposableContract(restartable = false)
fun LaunchedEffect(subject: Any?, block: suspend CoroutineScope.() -> Unit)
When LaunchedEffect enters the composition it will launch block into the composition's CoroutineContext.
@ComposableContract(restartable = false)
fun LaunchedEffect(vararg subjects: Any?, block: suspend CoroutineScope.() -> Unit)
When LaunchedEffect enters the composition it will launch block into the composition's CoroutineContext.
@ComposableContract(restartable = false)
fun LaunchedEffect(subject1: Any?, subject2: Any?, block: suspend CoroutineScope.() -> Unit)
When LaunchedEffect enters the composition it will launch block into the composition's CoroutineContext.
@ComposableContract(restartable = false)
fun LaunchedEffect(subject1: Any?, subject2: Any?, subject3: Any?, block: suspend CoroutineScope.() -> Unit)
When LaunchedEffect enters the composition it will launch block into the composition's CoroutineContext.
LaunchedTask
Link copied to clipboard
common
fun LaunchedTask(block: suspend CoroutineScope.() -> Unit)
When LaunchedTask enters the composition it will launch block into the composition's CoroutineContext.
fun LaunchedTask(key: Any?, block: suspend CoroutineScope.() -> Unit)
When LaunchedTask enters the composition it will launch block into the composition's CoroutineContext.
fun LaunchedTask(vararg keys: Any?, block: suspend CoroutineScope.() -> Unit)
When LaunchedTask enters the composition it will launch block into the composition's CoroutineContext.
fun LaunchedTask(key1: Any?, key2: Any?, block: suspend CoroutineScope.() -> Unit)
When LaunchedTask enters the composition it will launch block into the composition's CoroutineContext.
fun LaunchedTask(key1: Any?, key2: Any?, key3: Any?, block: suspend CoroutineScope.() -> Unit)
When LaunchedTask enters the composition it will launch block into the composition's CoroutineContext.
mutableStateListOf
Link copied to clipboard
common
fun <T> mutableStateListOf(): SnapshotStateList<T>
Create a instance of MutableList<T> that is observable and can be snapshot.
fun <T> mutableStateListOf(vararg elements: T): SnapshotStateList<T>
Create an instance of MutableList<T> that is observable and can be snapshot.
mutableStateMapOf
Link copied to clipboard
common
fun <K, V> mutableStateMapOf(): SnapshotStateMap<K, V>
Create a instance of MutableSet<K, V> that is observable and can be snapshot.
fun <K, V> mutableStateMapOf(vararg pairs: Pair<K, V>): SnapshotStateMap<K, V>
Create a instance of MutableMap<K, V> that is observable and can be snapshot.
mutableStateOf
Link copied to clipboard
common
fun <T> mutableStateOf(value: T, policy: SnapshotMutationPolicy<T> = structuralEqualityPolicy()): MutableState<T>
Return a new MutableState initialized with the passed in valueThe MutableState class is a single value holder whose reads and writes are observed by Compose.
neverEqualPolicy
Link copied to clipboard
common
fun <T> neverEqualPolicy(): SnapshotMutationPolicy<T>
A policy never treat values of a MutableState as equivalent.
onActive
Link copied to clipboard
common
fun onActive(callback: CommitScope.() -> Unit)
An effect used to observe the lifecycle of the composition.
onCommit
Link copied to clipboard
common
inline fun onCommit(noinline callback: CommitScope.() -> Unit)
The onCommit effect is a lifecycle effect that will execute callback every time the composition commits.
fun <V1> onCommit(v1: V1, callback: CommitScope.() -> Unit)
The onCommit effect is a lifecycle effect that will execute callback every time the inputs to the effect have changed.
fun onCommit(vararg inputs: Any?, callback: CommitScope.() -> Unit)
The onCommit effect is a lifecycle effect that will execute callback every time the inputs to the effect have changed.
fun <V1, V2> onCommit(v1: V1, v2: V2, callback: CommitScope.() -> Unit)
The onCommit effect is a lifecycle effect that will execute callback every time the inputs to the effect have changed.
onDispose
Link copied to clipboard
common
fun onDispose(callback: () -> Unit)
An effect used to schedule work to be done when the effect leaves the composition.
orEmpty
Link copied to clipboard
common
inline fun () -> Unit?.orEmpty(): () -> Unit
produceState
Link copied to clipboard
common
fun <T> produceState(initialValue: T, producer: suspend ProduceStateScope<T>.() -> Unit): State<T>
Return an observable snapshotState that produces values over time without a defined data source.
fun <T> produceState(initialValue: T, subject: Any?, producer: suspend ProduceStateScope<T>.() -> Unit): State<T>
Return an observable snapshotState that produces values over time from subject.
fun <T> produceState(initialValue: T, vararg subjects: Any?, producer: suspend ProduceStateScope<T>.() -> Unit): State<T>
Return an observable snapshotState that produces values over time from subjects.
fun <T> produceState(initialValue: T, subject1: Any?, subject2: Any?, producer: suspend ProduceStateScope<T>.() -> Unit): State<T>
Return an observable snapshotState that produces values over time from subject1 and subject2.
fun <T> produceState(initialValue: T, subject1: Any?, subject2: Any?, subject3: Any?, producer: suspend ProduceStateScope<T>.() -> Unit): State<T>
Return an observable snapshotState that produces values over time from subject1, subject2 and subject3.
Providers
Link copied to clipboard
common
fun Providers(vararg values: ProvidedValue<*>, content: () -> Unit)
Providers binds values to ProvidableAmbient keys.
referentialEqualityPolicy
Link copied to clipboard
common
fun <T> referentialEqualityPolicy(): SnapshotMutationPolicy<T>
A policy to treat values of a MutableState as equivalent if they are referentially (===) equal.
remember
Link copied to clipboard
common
inline fun <T> remember(calculation: () -> T): T
Remember the value produced by calculation.
inline fun <T, V1> remember(v1: V1, calculation: () -> T): T
Remember the value returned by calculation if v1 is equal to the previous composition, otherwise produce and remember a new value by calling calculation.
inline fun <V> remember(vararg inputs: Any?, calculation: () -> V): V
Remember the value returned by calculation if all values of inputs are equal to the previous composition, otherwise produce and remember a new value by calling calculation.
inline fun <T, V1, V2> remember(v1: V1, v2: V2, calculation: () -> T): T
Remember the value returned by calculation if v1 and v2 are equal to the previous composition, otherwise produce and remember a new value by calling calculation.
inline fun <T, V1, V2, V3> remember(v1: V1, v2: V2, v3: V3, calculation: () -> T): T
Remember the value returned by calculation if v1, v2 and v3 are equal to the previous composition, otherwise produce and remember a new value by calling calculation.
rememberCoroutineScope
Link copied to clipboard
common
inline fun rememberCoroutineScope(getContext: () -> CoroutineContext = { EmptyCoroutineContext }): CoroutineScope
Return a CoroutineScope bound to this point in the composition using the optional CoroutineContext provided by getContext.
rememberUpdatedState
Link copied to clipboard
common
inline fun <T> rememberUpdatedState(newValue: T): State<T>
remember a mutableStateOf and update its value to newValue on each recomposition of the rememberUpdatedState call.
resetSourceInfo
Link copied to clipboard
common
fun resetSourceInfo()
setValue
Link copied to clipboard
common
inline operator fun <T> MutableState<T>.setValue(thisObj: Any?, property: KProperty<*>, value: T)
Permits property delegation of vars using by for MutableState.
SideEffect
Link copied to clipboard
common
@ComposableContract(restartable = false)
fun SideEffect(effect: () -> Unit)
Schedule effect to run when the current composition completes successfully and applies changes.
simulateHotReload
Link copied to clipboard
common
fun simulateHotReload(context: Any)
slice
Link copied to clipboard
common
fun IntArray.slice(indices: Iterable<Int>): List<Int>
staticAmbientOf
Link copied to clipboard
common
fun <T> staticAmbientOf(defaultFactory: () -> T? = null): ProvidableAmbient<T>
Create an ambient key that can be provided using Providers.
structuralEqualityPolicy
Link copied to clipboard
common
fun <T> structuralEqualityPolicy(): SnapshotMutationPolicy<T>
A policy to treat values of a MutableState as equivalent if they are structurally (==) equal.
toMutableStateList
Link copied to clipboard
common
fun <T> Collection<T>.toMutableStateList(): SnapshotStateList<T>
Create an instance of MutableList<T> from a collection that is observerable and can be snapshot.
toMutableStateMap
Link copied to clipboard
common
fun <K, V> Iterable<Pair<K, V>>.toMutableStateMap(): SnapshotStateMap<K, V>
Create an instance of MutableMap<K, V> from a collection of pairs that is observable and can be snapshot.
withRunningRecomposer
Link copied to clipboard
common
suspend fun <R> withRunningRecomposer(block: suspend CoroutineScope.(recomposer: Recomposer) -> R): R
Runs block with a new, active Recomposer applying changes in the calling CoroutineContext.

Properties

currentComposer
Link copied to clipboard
common
val currentComposer: Composer<*>
invalidate
Link copied to clipboard
common
val invalidate: () -> Unit
An Effect to get the nearest invalidation lambda to the current point of composition.
yoloGlobalEmbeddingContext
Link copied to clipboard
var yoloGlobalEmbeddingContext: EmbeddingContext? = null