Navigation & coupeling #712
-
I'm currently exploring the Circuit UI framework and am interested in understanding how to ensure that my screens are decoupled from the navigation logic, similar to how it's done in the NowInAndroid sample which uses Jetpack Compose Navigation's NavHost and routes. In the NowInAndroid sample, screens themselves don't need to know anything about navigation. They just call a function like onTopicClick, and the function handles the navigation. Here's the relevant code snippet:
I would like to know how I could achieve similar decoupling using Circuit. I want my screens to just call a function for navigation events, and the function itself to handle the navigation. Is this possible with Circuit? If so, I'd appreciate guidance or advice on how to implement this. In addition, Is there anything else I should know about handling navigation in Circuit, especially in comparison to Jetpack Compose Navigation? Thank you! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 8 replies
-
Take a look at our navigation docs: https://slackhq.github.io/circuit/navigation/ Generally, all presenters need to know is the Screen it's going to and circuit will connect the rest. You can also implement a custom navigator and push your own logic inside of it, such as writing a navigation DSL |
Beta Was this translation helpful? Give feedback.
-
@ZacSweers Could you provide some insights into the benefits or reasons for choosing this navigation approach (which might seems to be tightly-coupled please fix me if i'm wrong) over an event-based as in NowInAndroid app? Are there specific advantages in terms of scaleability, code maintainability, or user experience that influenced this decision? Thanks! |
Beta Was this translation helpful? Give feedback.
Take a look at our navigation docs: https://slackhq.github.io/circuit/navigation/
Generally, all presenters need to know is the Screen it's going to and circuit will connect the rest.
You can also implement a custom navigator and push your own logic inside of it, such as writing a navigation DSL