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
mapToSuperRoute
or to specify a closure for themap
parameter. If you overridemapToSuperRoute
, themap
parameter is ignored.Declaration
Swift
public init(viewController: UIViewController, parent: UnownedRouter<ParentRoute>, map: ((RouteType) -> ParentRoute)?)
Parameters
viewController
The view controller to be used in transitions, e.g. when pushing, presenting or otherwise displaying the RedirectionRouter.
parent
Triggered routes will be rerouted to the parent router.
map
A 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) -> ParentRoute
Parameters
route
The route to be mapped.
Return Value
The mapped route for the parent router.