Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ViewModel never cleared #37

Closed
alextsymbaldev opened this issue Jan 6, 2022 · 1 comment
Closed

ViewModel never cleared #37

alextsymbaldev opened this issue Jan 6, 2022 · 1 comment

Comments

@alextsymbaldev
Copy link

alextsymbaldev commented Jan 6, 2022

Hi. I am using Voyager to navigate in a project built on the Orbit MVI and Koin libraries. Orbit requires a ViewModel to store the container, so i can't use ScreenModel. I am injecting the viewModel using the getVievModel from Koin in @composable override fun Content(). The problem is that when i'm leaving the screen using the pop() function, the viewModel is not cleared over the app life cycle and if i open the same screen again i have the same viewModel with preloaded data. How to deal with this? Thank you in advance!

@alextsymbaldev
Copy link
Author

Dealid using

@Composable
fun getComposeViewModelOwner(): ViewModelOwner {
    return ViewModelOwner.fromAny(getLifecycleOwner())
}

with AndroidScreen()

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant