androidx.compose.runtime

ProvidableCompositionLocal

Abstract class · from androidx.compose.runtime:runtime:1.12.1

No hand-written docs yet.

A ProvidableCompositionLocal can be used in CompositionLocalProvider to provide values.

abstract class ProvidableCompositionLocal<T> : CompositionLocal<T>

Is a

How to get one

Ready-made values and functions that return it

Functions

provides

fun provides(value: T): ProvidedValue<T>

Associates a CompositionLocal key to a value in a call to CompositionLocalProvider.

providesDefault

fun providesDefault(value: T): ProvidedValue<T>

Associates a CompositionLocal key to a value in a call to CompositionLocalProvider if the key does not already have an associated value.

providesComputed

fun providesComputed(
    compute: CompositionLocalAccessorScope.() -> T,
): ProvidedValue<T>

Associates a CompositionLocal key to a lambda, compute, in a call to CompositionLocal. The compute lambda is invoked whenever the key is retrieved. The lambda is executed in the context of a CompositionLocalContext which allow retrieving the current values of other composition locals by calling CompositionLocalAccessorScope.currentValue, which is an extension function provided by the context for a CompositionLocal key.

Library docs

A ProvidableCompositionLocal can be used in CompositionLocalProvider to provide values.