Implicit navigation¶

How can we go from one part of the tree to another? In almost all cases navigation can be implicit instead of explicit. We don't need to specify the target – navigation will happen as a consequence of individual pieces of the puzzle.
Relevant methods
- Node.onChildFinished(child: Node)can be overridden by client code to handle a child finishing
- Node.finish()invokes the above method on its parent
Use-case 1¶

Requirement¶
After onboarding finishes, the user should land in the message list screen.
Solution¶
- O3calls its- finish()method
- Onboardingnotices- O3finished; if it had more children, it could switch to another; now it calls- finish()too
- Logged innotices- Onboardingfinished, and switches its navigation to- Main
- Mainis initialised, and loads its default navigation target (based on product requirements) to be- Messages
- Messagesis initialised, and loads its default navigation target to be- List
Bonus
Every Node in the above sequence only needed to care about its own local concern.
Use-case 2¶

Requirement¶
Pressing the logout button on the profile screen should land us back to the login screen.
Solution¶
- Rooteither implements a- logoutcallback, or subscribes to the changes of a user repository; in both cases, either the callback or the repository is passed down the tree as a dependency
- Profileinvokes the callback or a- logoutmethod on the repository
- Rootnotices the state change, and switches its navigation to the- Logged outscope
- Logged outloads its initial navigation target,- Login
Bonus
Note how the entire Logged in scope is destroyed without any extra effort. The next time a login happens, all state is created anew. 
Summary¶
Implicit navigation allows you to implement navigation without introducing unnecessary coupling in the tree, and successfully covers the majority of navigation scenarios.
In case it's not enough to meet your needs, see the next chapter, Explicit navigation