RoutingInterceptor

public protocol RoutingInterceptor

RoutingInterceptor is called before the actual navigation process happens. e.g. user should be logged in.

NB

Interceptor is an asynchronous action. For the Router to continue the navigation process, the completion block of the interceptor’s execute method MUST be called. Otherwise, the Router will stay in a limbo state waiting for the interceptor to finish its action.

Associated types

  • Context type associated with RoutingInterceptor

    Declaration

    Swift

    associatedtype Context

Methods to implement

  • prepare(with:) Default implementation

    The Router will call this method before the navigation process. If RoutingInterceptor is not able to allow the navigation process to start it can stop Router by throwing an exception.

    Throws

    The RoutingError if the RoutingInterceptor cannot prepare itself or if the navigation process cannot start with the Context instance provided.

    Default Implementation

    Default implementation does nothing.

    Declaration

    Swift

    mutating func prepare(with context: Context) throws

    Parameters

    context

    The Context instance that is provided to the Router.

  • Method that will be called by Router to start interceptor.

    NB

    For the Router to continue the navigation process, the completion block of interceptor MUST be called by the implementation of this method. Otherwise Router will stay in limbo waiting for RoutingInterceptor to finish its action.

    Declaration

    Swift

    func perform(with context: Context, completion: @escaping (RoutingResult) -> Void)

    Parameters

    context

    Context instance provided to the Router

    completion

    Completion block with a result.

Helper methods

Available where Context == Any?

  • prepare() Extension method

    The Router will call this method before the navigation process. If RoutingInterceptor is not able to allow the navigation process to start it can stop Router by throwing an exception.

    Throws

    The RoutingError if the RoutingInterceptor cannot prepare itself or if the navigation process cannot start with the Context instance provided.

    Declaration

    Swift

    mutating func prepare() throws
  • perform(completion:) Extension method

    Method that will be called by Router to start interceptor.

    NB

    For the Router to continue the navigation process, the completion block of interceptor MUST be called by the implementation of this method. Otherwise Router will stay in limbo waiting for RoutingInterceptor to finish its action.

    Declaration

    Swift

    func perform(completion: @escaping (RoutingResult) -> Void)

    Parameters

    completion

    Completion block with a result.

  • execute(completion:) Extension method

    Prepares the RoutingInterceptor and executes it

    Declaration

    Swift

    func execute(completion: @escaping (RoutingResult) -> Void) throws
  • commit(completion:) Extension method

    Prepares the RoutingInterceptor and performs it. Does not throw an exception.

    Declaration

    Swift

    func commit(completion: @escaping (RoutingResult) -> Void)

Available where Context == Void

  • prepare() Extension method

    The Router will call this method before the navigation process. If RoutingInterceptor is not able to allow the navigation process to start it can stop Router by throwing an exception.

    Throws

    The RoutingError if the RoutingInterceptor cannot prepare itself or if the navigation process cannot start with the Context instance provided.

    Declaration

    Swift

    mutating func prepare() throws
  • perform(completion:) Extension method

    Method that will be called by Router to start interceptor.

    NB

    For the Router to continue the navigation process, the completion block of interceptor MUST be called by the implementation of this method. Otherwise Router will stay in limbo waiting for RoutingInterceptor to finish its action.

    Declaration

    Swift

    func perform(completion: @escaping (RoutingResult) -> Void)

    Parameters

    completion

    Completion block with a result.

  • execute(completion:) Extension method

    Prepares the RoutingInterceptor and executes it

    Declaration

    Swift

    func execute(completion: @escaping (RoutingResult) -> Void) throws
  • commit(completion:) Extension method

    Prepares the RoutingInterceptor and performs it. Does not throw an exception.

    Declaration

    Swift

    func commit(completion: @escaping (RoutingResult) -> Void)