For a very long time, we knew how a single top instance worked in the Fragment's navigation world. Since transactions in the FragmentManager are reversible the only way to correctly achieve this functionality of singleTop is to pop the backstack up to the point where we find that respective instance in the FragmentTransaction. This is how navigator & Jetpack Navigation handles single top functionality.
In Compose world, this could take a different turn since destinations are nothing but a State which we observe to switch between different composables we can remove it at any point without affecting the previous transaction (i.e history). The current implementation does not work like how it was done in Fragments world, here we just remove all the existing instances from the backstack directly (i.e no recursive pop till we find that instance).
This could be confusing since the functionality is not carried over to the new system. Now should I keep or change the logic that we are familiar with Fragments? Changing it would then become a breaking change.
For a very long time, we knew how a single top instance worked in the
Fragment
's navigation world. Since transactions in theFragmentManager
are reversible the only way to correctly achieve this functionality ofsingleTop
is to pop the backstack up to the point where we find that respective instance in theFragmentTransaction
. This is hownavigator
& Jetpack Navigation handles single top functionality.In Compose world, this could take a different turn since destinations are nothing but a
State
which we observe to switch between different composables we can remove it at any point without affecting the previous transaction (i.e history). The current implementation does not work like how it was done in Fragments world, here we just remove all the existing instances from the backstack directly (i.e no recursive pop till we find that instance).This could be confusing since the functionality is not carried over to the new system. Now should I keep or change the logic that we are familiar with Fragments? Changing it would then become a breaking change.