Hey guys! Me question is about koin + android navi...
# koin
m
Hey guys! Me question is about koin + android navigation with multiple backstack. If u have implemented multiple backstack with android navigation then u know that fragment containers fully recreates when switch between them. What is your experience how to deal with it? Fragment still stay in FragmentManager that's why ViewModel do not destroyed, but if we use koin's fragmentScope, then scope closes every time we switch stack. It leads to inconsistency because koin scope recreates, and previous instances still in VM, but if we need to provide this instances more times, it creates new instances. For now, as I figured it out, possible solution is to refuse from handling fragment's lifecycle to close koin scope and handle events like onBackPressed to surely now when we will not return to this fragment. Any ideas?
a
did you tried Navigation ViewModel then?
m
Do you mean koinViewModelNavGraph?
a
yes
m
I don't need to share my VM
There is different VMs for each fragment
a
then if you use scope, it conflicts with VM
Fragment scope is shorter life time than VM