https://kotlinlang.org logo
#squarelibraries
Title
# squarelibraries
s

spierce7

12/08/2023, 5:53 PM
With Molecule, I've been playing around with the idea of accessing the Navigator via Composition Local, so that our business logic can own the navigation instead of the View layer. Molecule seems to run in a separate Composition scope though, so any
CompositionLocal
s are not available inside of it. I'm running Molecule inside of a
ViewModel
anyways, and was playing around with the potentially bad idea of creating a provider that bridges between the different composable scopes for the Navigator. I was curious if anyone could provide any insight to the cons of doing this.
e

efemoney

12/08/2023, 6:12 PM
Surely, its easier to just inject your navigator no? The underlying problem here (I’m guessing) is that navigator is tied to UI. Fx that then inject it safely into business logic, maybe
s

spierce7

12/08/2023, 6:13 PM
I'm using Voyager. The navigator is tied to the Composable. https://voyager.adriel.cafe/navigation#navigator
s

saket

12/08/2023, 6:38 PM
do your presenters outlive your UI? in that case, you'd want to make sure that your presenters don't leak memory by holding a reference to UI-scoped navigators
1
fwiw I'm injecting a
State<Navigator>
in my presenters whose value gets updated on every Activity creation