ReSwift-Router icon indicating copy to clipboard operation
ReSwift-Router copied to clipboard

handle route globally

Open AlexanderBollbach opened this issue 6 years ago • 2 comments

My understanding of NavigationState.route is that each of its RouteElementIdentifier elements corresponds to a Routable that is triggered. So if my route state goes from ["home"] to ["home", "favorites"] than the root Routable will push FavoritesVC (for example). So each successive RouteElementIdentifier that is appended during a SetRouteAction([] hands control off to a new Routable.

But what if I want to push a loading screen as the 3rd Routable. A loading screen could be presented from any VC. Is there a way to define the routing to a loading screen (say by presenting LoadingVC modally) once and have FavoritesVC inherit the ability? Because a ProfileVC along with 10 other VC's would reasonably present a loading screen.

AlexanderBollbach avatar Apr 18 '18 05:04 AlexanderBollbach

I currently have this implemented, but my global view is a Menu. I approached this by making a protocol, MenuDelegate that requires the implementation of my showMenu() function. This function triggers access to the MenuVC just like any other view, and it can dismiss itself as well.

Would an approach like that work for your use case? This is a problem I'm trying to improve upon myself.

trentguillory avatar Apr 27 '18 16:04 trentguillory

@trentguillory @mjarvis i thought of another way to do this. but it would involve changing the library. looking at the source, (specifically Router<T>.routingActionsForTransitionFrom), if my routing state goes from ["foo"] to ["foo", "bar"], than the Routable pushed for "foo" is charged with routing to "bar". Is it possible to extend ReSwiftRouter such that the "bar" route could be handled only by the Routable for "foo"?

AlexanderBollbach avatar Jun 02 '18 03:06 AlexanderBollbach