Kodein integration¶
Success
To use the rememberScreenModel
you should first import cafe.adriel.voyager:voyager-kodein
(see Setup).
Declare your ScreenModel
s using the bindProvider
bind.
val homeModule = DI.Module(name = "home") {
bindProvider { HomeScreenModel() }
}
Call rememberScreenModel()
to get a new instance.
class HomeScreen : Screen {
@Composable
override fun Content() {
val screenModel = rememberScreenModel<HomeScreenModel>()
// ...
}
}
Sample¶
Info
Sample code here.
Navigator scoped ScreenModel¶
class HomeScreen : Screen {
@Composable
override fun Content() {
val navigator = LocalNavigator.currentOrThrow
val screenModel = navigator.rememberNavigatorScreenModel<HomeScreenModel>()
// ...
}
}