Coordinator
public protocol Coordinator : Router, TransitionPerformer
Coordinator is the protocol every coordinator conforms to.
It requires an object to be able to trigger routes and perform transitions.
This connection is created using the prepareTransition(for:)
method.
-
This method prepares transitions for routes. It especially decides, which transitions are performed for the triggered routes.
Declaration
Swift
func prepareTransition(for route: RouteType) -> TransitionType
Parameters
route
The triggered route for which a transition is to be prepared.
Return Value
The prepared transition.
-
This method adds a child to a coordinator’s children.
Declaration
Swift
func addChild(_ presentable: Presentable)
Parameters
presentable
The child to be added.
-
This method removes a child to a coordinator’s children.
Declaration
Swift
func removeChild(_ presentable: Presentable)
Parameters
presentable
The child to be removed.
-
This method removes all children that are no longer in the view hierarchy.
Declaration
Swift
func removeChildrenIfNeeded()
-
RootViewController
Extension methodShortcut for Coordinator.TransitionType.RootViewController
Declaration
Swift
public typealias RootViewController = TransitionType.RootViewController
-
viewController
Extension methodA Coordinator uses its rootViewController as viewController.
Declaration
Swift
public var viewController: UIViewController! { get }
-
weakRouter
Extension methodCreates a WeakRouter object from the given router to abstract from concrete implementations while maintaining information necessary to fulfill the Router protocol. The original router will be held weakly.
Declaration
Swift
public var weakRouter: WeakRouter<RouteType> { get }
-
unownedRouter
Extension methodCreates an UnownedRouter object from the given router to abstract from concrete implementations while maintaining information necessary to fulfill the Router protocol. The original router will be held unowned.
Declaration
Swift
public var unownedRouter: UnownedRouter<RouteType> { get }
-
anyCoordinator
Extension methodCreates an AnyCoordinator based on the current coordinator.
Declaration
Swift
public var anyCoordinator: AnyCoordinator<RouteType, TransitionType> { get }
-
presented(from:)
Extension methodDeclaration
Swift
public func presented(from presentable: Presentable?)
-
childTransitionCompleted()
Extension methodDeclaration
Swift
public func childTransitionCompleted()
-
contextTrigger(_:with:completion:)
Extension methodDeclaration
Swift
public func contextTrigger(_ route: RouteType, with options: TransitionOptions, completion: ContextPresentationHandler?)
-
chain(routes:)
Extension methodWith
chain(routes:)
different routes can be chained together to form a combined transition.Declaration
Swift
public func chain(routes: [RouteType]) -> TransitionType
Parameters
routes
The routes to be chained.
Return Value
A transition combining the transitions of the specified routes.
-
performTransition(_:with:completion:)
Extension methodDeclaration
Swift
public func performTransition(_ transition: TransitionType, with options: TransitionOptions, completion: PresentationHandler? = nil)
-
deepLink(_:_:)
Extension methodDeep-Linking can be used to chain routes of different types together.
Note
Use it with caution, as it is not implemented in a type-safe manner. Keep in mind that changes in the app’s structure and changes of transitions behind the given routes can lead to runtime errors and, therefore, crashes of your app.
Declaration
Swift
public func deepLink<RootViewController, S: Sequence>(_ route: RouteType, _ remainingRoutes: S) -> Transition<RootViewController> where S.Element == Route, TransitionType == Transition<RootViewController>
Parameters
route
The first route in the chain. It is given a special place because its exact type can be specified.
remainingRoutes
The remaining routes of the chain.
-
deepLink(_:_:)
Extension methodDeep-Linking can be used to chain routes of different types together.
Declaration
Swift
public func deepLink<RootViewController>(_ route: RouteType, _ remainingRoutes: Route...) -> Transition<RootViewController> where TransitionType == Transition<RootViewController>
-
registerPeek(for:route:)
Extension methodUse this transition to register 3D Touch Peek and Pop functionality.
Declaration
Swift
@available(iOS, introduced: 9.0, deprecated: 13.0, message: "Use `UIContextMenuInteraction` instead.") public func registerPeek<RootViewController>(for source: Container, route: RouteType ) -> Transition<RootViewController> where Self.TransitionType == Transition<RootViewController>
Parameters
source
The view to register peek and pop on.
route
The route to be triggered for peek and pop.