Tree composition support and runtime infrastructure for Compose Multiplatform desktop applications with declarative UI development APIs.
npx @tessl/cli install tessl/maven-org-jetbrains-compose-runtime--runtime-desktop@1.8.0Compose Runtime Desktop provides the core runtime infrastructure for building declarative user interfaces with Compose Multiplatform on desktop platforms (Windows, macOS, Linux). It includes tree composition support, state management, recomposition logic, and the foundational APIs needed for reactive UI development.
build.gradle.kts dependenciesdependencies {
implementation("org.jetbrains.compose.runtime:runtime-desktop:1.8.2")
}import androidx.compose.runtime.*For specific functionalities:
import androidx.compose.runtime.Composable
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.DisposableEffect
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.derivedStateOf
import androidx.compose.runtime.produceStateimport androidx.compose.runtime.*
@Composable
fun Counter() {
var count by remember { mutableStateOf(0) }
Button(
onClick = { count++ }
) {
Text("Count: $count")
}
}
@Composable
fun App() {
var name by remember { mutableStateOf("World") }
Column {
TextField(
value = name,
onValueChange = { name = it },
label = { Text("Name") }
)
Text("Hello, $name!")
}
}Compose Runtime Desktop is built around several key components:
Core state management APIs for creating reactive UI state that automatically triggers recomposition when changed.
fun <T> mutableStateOf(
value: T,
policy: SnapshotMutationPolicy<T> = structuralEqualityPolicy()
): MutableState<T>
interface State<out T> {
val value: T
}
interface MutableState<T> : State<T> {
override var value: T
}Side effect APIs for integrating with external systems, managing resources, and handling component lifecycle.
@Composable
fun LaunchedEffect(
vararg keys: Any?,
block: suspend CoroutineScope.() -> Unit
)
@Composable
fun DisposableEffect(
vararg keys: Any?,
effect: DisposableEffectScope.() -> DisposableEffectResult
)
@Composable
fun SideEffect(effect: () -> Unit)Core composition APIs for building composable functions and managing implicit context propagation.
@Target(AnnotationTarget.FUNCTION, AnnotationTarget.TYPE)
@Retention(AnnotationRetention.BINARY)
annotation class Composable
@Composable
fun <T> remember(calculation: () -> T): T
@Composable
fun CompositionLocalProvider(
vararg values: ProvidedValue<*>,
content: @Composable () -> Unit
)Reactive collections and observable data structures that integrate with the composition system.
fun <T> mutableStateListOf(vararg elements: T): SnapshotStateList<T>
fun <K, V> mutableStateMapOf(vararg pairs: Pair<K, V>): SnapshotStateMap<K, V>
@Composable
fun <T> Flow<T>.collectAsState(
initial: T,
context: CoroutineContext = EmptyCoroutineContext
): State<T>