CompositionLocalMap
public sealed interface CompositionLocalMap
A read-only, immutable snapshot of the CompositionLocals
that are set at a
specific position in the composition hierarchy.
Functions
public operator fun <T> 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.