Router

@MainActor
public protocol Router

Base router protocol.

Methods to implement

  • Navigates the application to the view controller configured in DestinationStep with the Context provided.

    Declaration

    Swift

    @MainActor
    func navigate<Context>(to step: DestinationStep<some UIViewController, Context>,
                           with context: Context,
                           animated: Bool,
                           completion: ((_: RoutingResult) -> Void)?) throws

    Parameters

    step

    DestinationStep instance.

    context

    Context instance.

    animated

    if true - the navigation should be animated where it is possible.

    completion

    completion block.

Navigation methods for the Destination instance

  • Navigates the application to the view controller configured in Destination with the Context provided.

    Declaration

    Swift

    @MainActor
    func navigate(to destination: Destination<some UIViewController, some Any>, animated: Bool = true, completion: ((RoutingResult) -> Void)? = nil) throws

    Parameters

    destination

    Destination instance.

    animated

    if true - the navigation should be animated where it is possible.

    completion

    completion block.

  • Navigates the application to the view controller configured in Destination with the Context provided. Method does not throw errors, but propagates them to the completion block.

    Declaration

    Swift

    @MainActor
    func commitNavigation(to destination: Destination<some UIViewController, some Any>, animated: Bool = true, completion: ((RoutingResult) -> Void)? = nil)

    Parameters

    destination

    Destination instance.

    animated

    if true - the navigation should be animated where it is possible.

    completion

    completion block.

Helper methods

  • navigate(to:with:animated:) Extension method, asynchronous

    Navigates the application to the view controller configured in DestinationStep with the Context provided.

    Declaration

    Swift

    @available(iOS 13.0.0, *)
    @MainActor
    func navigate<Context>(to step: DestinationStep<some UIViewController, Context>,
                           with context: Context,
                           animated: Bool) async throws

    Parameters

    step

    DestinationStep instance.

    context

    Context instance.

    animated

    if true - the navigation should be animated where it is possible.

  • Navigates the application to the view controller configured in DestinationStep with the Context set to Any?.

    Declaration

    Swift

    @MainActor
    func navigate(to step: DestinationStep<some UIViewController, Any?>,
                  animated: Bool,
                  completion: ((_: RoutingResult) -> Void)?) throws

    Parameters

    step

    DestinationStep instance.

    animated

    if true - the navigation should be animated where it is possible.

    completion

    completion block.

  • navigate(to:animated:) Extension method, asynchronous

    Navigates the application to the view controller configured in DestinationStep with the Context set to Any?.

    Declaration

    Swift

    @available(iOS 13.0.0, *)
    @MainActor
    func navigate(to step: DestinationStep<some UIViewController, Any?>,
                  animated: Bool) async throws

    Parameters

    step

    DestinationStep instance.

    animated

    if true - the navigation should be animated where it is possible.

  • Navigates the application to the view controller configured in DestinationStep with the Context set to Void.

    Declaration

    Swift

    @MainActor
    func navigate(to step: DestinationStep<some UIViewController, Void>,
                  animated: Bool,
                  completion: ((_: RoutingResult) -> Void)?) throws

    Parameters

    step

    DestinationStep instance.

    animated

    if true - the navigation should be animated where it is possible.

    completion

    completion block.

  • navigate(to:animated:) Extension method, asynchronous

    Navigates the application to the view controller configured in DestinationStep with the Context set to Void.

    Declaration

    Swift

    @available(iOS 13.0.0, *)
    @MainActor
    func navigate(to step: DestinationStep<some UIViewController, Void>,
                  animated: Bool) async throws

    Parameters

    step

    DestinationStep instance.

    animated

    if true - the navigation should be animated where it is possible.

Navigation without the exception throwing

  • Navigates the application to the view controller configured in DestinationStep with the Context provided. Method does not throw errors, but propagates them to the completion block

    Declaration

    Swift

    @MainActor
    func commitNavigation<Context>(to step: DestinationStep<some UIViewController, Context>,
                                   with context: Context,
                                   animated: Bool,
                                   completion: ((RoutingResult) -> Void)?)

    Parameters

    step

    DestinationStep instance.

    context

    Context instance.

    animated

    if true - the navigation should be animated where it is possible.

    completion

    completion block.

  • Navigates the application to the view controller configured in DestinationStep with the Context set to Any?. Method does not throw errors, but propagates them to the completion block

    Declaration

    Swift

    @MainActor
    func commitNavigation(to step: DestinationStep<some UIViewController, Any?>,
                          animated: Bool,
                          completion: ((RoutingResult) -> Void)?)

    Parameters

    step

    DestinationStep instance.

    animated

    if true - the navigation should be animated where it is possible.

    completion

    completion block.

  • Navigates the application to the view controller configured in DestinationStep with the Context set to Void. Method does not throw errors, but propagates them to the completion block

    Declaration

    Swift

    @MainActor
    func commitNavigation(to step: DestinationStep<some UIViewController, Void>,
                          animated: Bool,
                          completion: ((RoutingResult) -> Void)?)

    Parameters

    step

    DestinationStep instance.

    animated

    if true - the navigation should be animated where it is possible.

    completion

    completion block.