Navigating between scoped Screens #1835
-
Related to this statement (from #1634), I have two typical Anvil scopes—a parent scope, @CircuitInject(SignInScreen::class, AppScope::class)
class SignInPresenter @Inject constructor(...) : Presenter<SignInState> { ... }
@CircuitInject(HomeScreen::class, LoggedInScope::class)
class HomePresenter @Inject constructor(...) : Presenter<HomeState> { ... } However, it's unclear how to navigate from an Is there an example of how to achieve this? Is this even considered "good DI"? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
I just realized my |
Beta Was this translation helpful? Give feedback.
-
I'm curious if there is a concrete example / code sample of how this actually works. I'm trying to figure out the best practice for navigating between scopes. Specifically, how to structure an AppScope and LoggedInScope which defines a UserSession instance which can then be injected to Presenter constructors. I found this example from Amazon App Platform which isn't Circuit specific but I think demonstrates how to solve this problem with kotlin-inject-anvil. Not sure if this is the best solution in the context of Circuit though. |
Beta Was this translation helpful? Give feedback.
I just realized my
Circuit
instance isAppScope
-ed. AFAIK the only way around this is to create aLoggedInScope
-edCircuit
and launch aLoggedInScope
-edActivity
.