screen

actual inline fun <Args, VM : ViewModel> screen(route: String, noinline viewModelWithArgs: (args: Args?) -> VM, noinline content: (viewModel: VM) -> Unit)
actual fun <VM : ViewModel> screen(route: String, viewModelFactory: () -> VM, content: (viewModel: VM) -> Unit)
expect inline fun <Args, VM : ViewModel> screen(route: String, noinline viewModelWithArgs: @Composable (args: Args?) -> VM, noinline content: @Composable (viewModel: VM) -> Unit)

Declare screen content for route and add it to underlying screens map. The screens map will be used to navigate between the screens.

Parameters

VM

generic type of ViewModel

route

used to identify the screen when navigating, in order to present it's content

viewModelWithArgs

lambda that takes screen arguments as a parameter and creates ViewModel that is later passed to screen content lambda

content

Composable lambda with content of the screen that takes view model as a parameter

Throws

when attempting to add new screen for already registered route


expect fun <VM : ViewModel> screen(route: String, viewModelFactory: @Composable () -> VM, content: @Composable (viewModel: VM) -> Unit)

Alternative implementation of screen that does not pass any arguments.

See also

actual inline fun <Args, VM : ViewModel> screen(route: String, noinline viewModelWithArgs: (args: Args?) -> VM, noinline content: (viewModel: VM) -> Unit)
actual fun <VM : ViewModel> screen(route: String, viewModelFactory: () -> VM, content: (viewModel: VM) -> Unit)