Having a KMP/compose multiplatform Project (mainly Android&Desktop) and need to scope(koin) my ScreenModel for Android-Lifecycle Reasons (in particular I am injecting a class that requires an activity to call and Android-API). In order to inject the screenmodel now, I have 2 different implementations of the screen, for Android & Desktop (no need for the scope on desktop).
Implementation on desktop:
class SignInScreen : Screen {
@Composable
override fun Content() {
val viewmodel = getScreenModel<SignInViewModel>()
AppTheme {
Surface {
ShowSignInScreen(
viewmodel = viewmodel
)
}
}
}
}
Implementation for Android:
class AndroidSignInScreen(private val scope: Scope) : Screen {
@Composable
override fun Content() {
val viewmodel by scope.inject<SignInViewModel>()
AppTheme {
Surface {
ShowSignInScreen(
viewmodel = viewmodel
)
}
}
}
}
My questions:
Is there a way I can avoid the Android specific implementation? (prefered)
Is there a way I can use getScreenModel on a scope? I read about navigation scoped screenmodels can this help somehow?
In ideal case the only difference between the platform implementations is the DI setup (sadly, I don't get rid of the scope on android => ideas are welcome, even though they don't belong here)
I am struggeling with following problem:
Having a KMP/compose multiplatform Project (mainly Android&Desktop) and need to scope(koin) my ScreenModel for Android-Lifecycle Reasons (in particular I am injecting a class that requires an activity to call and Android-API). In order to inject the screenmodel now, I have 2 different implementations of the screen, for Android & Desktop (no need for the scope on desktop).
Implementation on desktop:
Implementation for Android:
My questions:
getScreenModel
on a scope? I read about navigation scoped screenmodels can this help somehow?In ideal case the only difference between the platform implementations is the DI setup (sadly, I don't get rid of the scope on android => ideas are welcome, even though they don't belong here)