-
Hi. I wonder if the behavior of back callback invocation is calling by priority across children of a component with more than one stack? In my own little investigation I found different behavior on Android and desktop (It's too and abstracted away to provide a reproducer). SomeComponent {
> stack1
> stack2
} In desktop, It's possible to rely on callback priority for the children. Meaning if Thanks in advance! p.s. I feel handling back press becomes hard pretty quickly when it comes to more than one stack, especially recently. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
There should be no difference in back handling depending on the platform, as all the code is multiplatform. Assuming you drive the root lifecycle on desktop (e.g. by using The logic is pretty simple. Each Child Stack registers two back callbacks when So there is a tree of callbacks. When the back button is pressed, the call is propagated from the root down the tree. On each level the latest enabled callback with the highest priority is selected and the recursion continues until a leaf callback is found and called. |
Beta Was this translation helpful? Give feedback.
-
That's exactly the case.
I hold a reference to the Thanks for the clarification! Now that the process is clear, I guess the issue is on me. |
Beta Was this translation helpful? Give feedback.
There should be no difference in back handling depending on the platform, as all the code is multiplatform. Assuming you drive the root lifecycle on desktop (e.g. by using
LifecycleController
). Also it's not clear how do you trigger the back button on desktop?The logic is pretty simple.
Each Child Stack registers two back callbacks when
childStack
function is called. One callback with priority equal toPRIORITY_DEFAULT + 1
for the currently active child component, and another callback with priority equal toPRIORITY_DEFAULT
for the stack itself. The former callback allows the active component to intercept the back button. This callbacks is only enabled when there is an inner enabled call…