awaitApplication
An entry point for the Compose application that suspends until the application ends, leaving the thread it was awaited on free.
The application can launch background tasks using androidx.compose.runtime.LaunchedEffect or create Window, Dialog, or org.jetbrains.compose.swing.components.Tray in a declarative Compose way:
fun main() = runBlocking {
awaitApplication {
var isSplashScreenShowing by remember { mutableStateOf(true) }
LaunchedEffect(Unit) {
delay(2000)
isSplashScreenShowing = false
}
if (isSplashScreenShowing) {
Window(::exitApplication, title = "Splash") {}
} else {
Window(::exitApplication, title = "App") {}
}
}
}When there are no active compositions left, this function ends. An active composition is one that has an active coroutine (for example, launched in androidx.compose.runtime.LaunchedEffect) or a child composition created inside Window, Dialog, or org.jetbrains.compose.swing.components.Tray.
Animations driven in this composition (for example via androidx.compose.runtime.withFrameNanos or org.jetbrains.compose.swing.animation.core.animateFloatAsState) advance on the application's frame clock, which ticks at a fixed nominal rate. For animation paced to a display's refresh rate, drive it in a composition mounted with org.jetbrains.compose.swing.setContent, whose frame clock follows the hosting window's display.
Window and Dialog created inside content run as part of this application composition: application-scope state and any androidx.compose.runtime.CompositionLocal provided in content flow into their content.
Parameters
the application's content, composed against an ApplicationScope on the Event Dispatch Thread, whatever thread this is awaited on.