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 method

    Shortcut for Coordinator.TransitionType.RootViewController

    Declaration

    Swift

    public typealias RootViewController = TransitionType.RootViewController
  • viewController Extension method

    A Coordinator uses its rootViewController as viewController.

    Declaration

    Swift

    public var viewController: UIViewController! { get }
  • weakRouter Extension method

    Creates 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 method

    Creates 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 }
  • deepLink(_:_:) Extension method

    Deep-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 method

    Deep-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>