CompositionLocalMap


A read-only, immutable snapshot of the CompositionLocals that are set at a specific position in the composition hierarchy.

Summary

Public companion properties

CompositionLocalMap

An empty CompositionLocalMap instance which contains no keys or values.

Cmn

Public functions

operator T
<T : Any?> get(key: CompositionLocal<T>)

Returns the value of the provided composition local at the position in the composition hierarchy represented by this CompositionLocalMap instance.

Cmn

Public companion properties

Empty

val EmptyCompositionLocalMap

An empty CompositionLocalMap instance which contains no keys or values.

Public functions

get

operator fun <T : Any?> get(key: CompositionLocal<T>): T

Returns the value of the provided composition local at the position in the composition hierarchy represented by this CompositionLocalMap instance. If the provided key is not set at this point in the hierarchy, its default value will be used.

For non-static CompositionLocals, this function will return the latest value of the CompositionLocal, which might change over time across the same instance of the CompositionLocalMap. Reads done in this way are not tracked in the snapshot system.

For static CompositionLocals, this function returns the value at the time of creation of the CompositionLocalMap. When a static CompositionLocal is reassigned, the entire composition hierarchy is recomposed and a new CompositionLocalMap is created with the updated value of the static CompositionLocal.