RedirectionRouter
RedirectionRouters can be used to extract routes into different route types. Instead of having one huge route and one or more huge coordinators, you can create separate redirecting routers.
Create a RedirectionRouter from a parent router by providing a reference to that parent.
Triggered routes of the RedirectionRouter will be redirected to this parent router according to the provided mapping.
Please provide either a map closure in the initializer or override the mapToParentRoute method.
A RedirectionRouter has a viewController which is used in transitions, e.g. when you are presenting, pushing, or otherwise displaying it.
-
A type-erased Router object of the parent router.
Declaration
Swift
public let parent: UnownedRouter<ParentRoute>
-
The viewController used in transitions, e.g. when pushing, presenting or otherwise displaying the RedirectionRouter.
Declaration
Swift
public private(set) var viewController: UIViewController!
-
Creates a RedirectionRouter with a certain viewController, a parent router and an optional mapping.
Note
Make sure to either override
mapToSuperRouteor to specify a closure for themapparameter. If you overridemapToSuperRoute, themapparameter is ignored.Declaration
Swift
public init(viewController: UIViewController, parent: UnownedRouter<ParentRoute>, map: ((RouteType) -> ParentRoute)?)Parameters
viewControllerThe view controller to be used in transitions, e.g. when pushing, presenting or otherwise displaying the RedirectionRouter.
parentTriggered routes will be rerouted to the parent router.
mapA mapping from this RedirectionRouter’s routes to the parent’s routes.
-
Declaration
Swift
open func contextTrigger(_ route: RouteType, with options: TransitionOptions, completion: ContextPresentationHandler?) -
Map RouteType to ParentRoute.
This method is called when a route is triggered in the RedirectionRouter. It is used to translate RouteType routes to the parent’s routes which are then triggered in the parent router.
Declaration
Swift
open func mapToParentRoute(_ route: RouteType) -> ParentRouteParameters
routeThe route to be mapped.
Return Value
The mapped route for the parent router.
View on GitHub
RedirectionRouter Class Reference