Value
A readonly observable value interface.
Value<T> represents a value that can be read but not directly mutated through this interface. It serves as the foundational abstraction for all observable values in Litho, enabling:
Type-safe readonly access: Functions that only need to read can accept
Value<T>Specialized implementations: Different value types with different behaviors
Deferred reads: Style APIs can store
Value<T>and read during appropriate phasesAutomatic optimization: Phase-based read tracking enables targeted updates
Example Usage
// Reading a value
val count: Value<Int> = ...
Text("Count: ${count.value}")
// Passing to Style APIs (deferred read)
val alpha: Value<Float> = useAnimatedFloat(1f)
Style.alpha(alpha) // Read deferred to bind phase
// Functions accepting readonly values
fun formatValue(value: Value<Int>): String {
return "Value is ${value.value}"
}Content copied to clipboard
See also
for an updatable Value implementation