You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am working on a KMM project and facing an issue with my Android app. The iOS app works perfectly, but the Android app restarts and recreates the whole activity each time I minimize it.
The text was updated successfully, but these errors were encountered:
No, and I just found the problem. Initially, I was passing the viewModels directly to the screens. I created a viewModelFactory to avoid the need to pass it each time, to facilitate testing later:
class ViewModelFactory : KoinComponent {
inline fun <reified T : ScreenModel, reified P> getViewModel(parameter: P): T {
val viewModel: T by inject { parametersOf(parameter) }
return viewModel
}
inline fun <reified T: ScreenModel> getViewModel(): T {
val viewModel: T by inject()
return viewModel
}
}
I noticed from another issue that removing "then" and calling the viewModel using the getScreenModel function from the screen content should fix the problem, and it actually did in my case. But it would still be nice if we could directly pass the viewModel in the parameter, as I mentioned earlier, to make testing easier.
I am working on a KMM project and facing an issue with my Android app. The iOS app works perfectly, but the Android app restarts and recreates the whole activity each time I minimize it.
The text was updated successfully, but these errors were encountered: