Package-level declarations

Types

Link copied to clipboard

A build-time "CompositionLocal for mosaic-server" — a ThreadLocal-backed ambient value store, modeled directly on Jetpack Compose's own CompositionLocal mechanism, letting a value set by an outer block of the DSL (via CompositionLocalProvider) reach a builder several levels deep without every intermediate function threading it through as an explicit parameter.

Link copied to clipboard
data class CompositionLocal<T>(val type: KClass<*>, val defaultValue: () -> T)

A build-time equivalent of Compose's CompositionLocal: a typed slot that DSL code can read (current) without it being threaded explicitly through every builder call, and that a scope of the tree can override for its descendants via CompositionLocalProvider. Used internally by builders that need ambient state (e.g. the current lazy-item/row/column scope) during tile composition.

Link copied to clipboard
data class ValueProvider<T>(value: T)

Holds a value provided for a CompositionLocal inside a CompositionLocalProvider block.

Functions

Link copied to clipboard
inline fun <T> compositionLocalOf(noinline defaultValue: () -> T): CompositionLocal<T>

Declares a new CompositionLocal of type T, falling back to defaultValue when unset.

Link copied to clipboard
fun <T : GenericBuilderScope<*, *>> T.CompositionLocalProvider(vararg providedValues: Pair<CompositionLocal<*>, ValueProvider<*>>, content: T.() -> Unit)

Runs content with providedValues overriding their respective CompositionLocals for the duration of the block — descendants built inside content see the new values via CompositionLocal.current; once the block returns, the previous values are restored.

Link copied to clipboard

Reads the value currently provided for this CompositionLocal, or its CompositionLocal.defaultValue if none was provided.