Considering that I would like to have a custom `Na...
# koin
i
Considering that I would like to have a custom
NavManager
class that requires
NavController
(Android Navigation Component) as collabolator. What would be the best way to define Koin binding for
NavManager
class? How instance to
NavController
could be retrieved (from current Activity?)
Copy code
class NavManager(private val navController: NavController) {

    fun navigate(navDirections: NavDirections) {
        navController?.navigate(navDirections)
    }
}
t
The
NavController
is bound to the Android lifecycle of its host. I’d suggest to not provide it as a dependency. Instead you could provide a
LiveData
of navigation destinations. Then you just observe it within the scope of the navigation and provide data from whereever you need to.
i
I am also considering this alternative, but it also has certain downsides