With Molecule, I've been playing around with the i...
# squarelibraries
s
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
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
I'm using Voyager. The navigator is tied to the Composable. https://voyager.adriel.cafe/navigation#navigator
s
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