I actually had a similar setup in service-tree ages ago, but this time there's a chance it'll actually make sense :wink:
Currently to dispatch back event to your current active view, you generally select the current active view through the view hierarchy, by defining a custom boolean onBackPressed() that is delegated down to the current active-most view, which is actually quite tricky if you have a multi-step flow or a ViewPager.
Clearly, it is not even the responsibility of the View layer to know who's supposed to handle back presses. It should be the responsibility of the "active ViewModel" (or something similar). Therefore, the "active ViewModel" that can handle back should be found by simple-stack and should handle back if necessary, and only goBack() when no services in the active chain have handled back.
The question however is whether this should be a new behavior of backstack.goBack() (as the behavior is opt-in, because you need to implement an interface, it would not be breaking), or if it should be a separate method such as backstack.dispatchBack() that would be wrapped in Navigator/BackstackDelegate. :thinking:
I actually had a similar setup in service-tree ages ago, but this time there's a chance it'll actually make sense :wink:
Currently to dispatch
back
event to your current active view, you generally select the current active view through the view hierarchy, by defining a customboolean onBackPressed()
that is delegated down to the current active-most view, which is actually quite tricky if you have a multi-step flow or a ViewPager.Clearly, it is not even the responsibility of the View layer to know who's supposed to handle back presses. It should be the responsibility of the "active ViewModel" (or something similar). Therefore, the "active ViewModel" that can handle back should be found by simple-stack and should handle back if necessary, and only
goBack()
when no services in the active chain have handled back.The question however is whether this should be a new behavior of
backstack.goBack()
(as the behavior is opt-in, because you need to implement an interface, it would not be breaking), or if it should be a separate method such asbackstack.dispatchBack()
that would be wrapped inNavigator
/BackstackDelegate
. :thinking: