XRouter

open class XRouter<R> : RouteHandler<R> where R : RouteType

A routing appliance used to navigate to the start of flows.

router.navigate(to: .profile(withID: 23))

Properties

  • UIWindow. Defaults to UIApplication.shared.keyWindow.

    Declaration

    Swift

    public lazy var window: UIWindow? { get set }
  • Route handler. Defaults to self.

    Declaration

    Swift

    public lazy var routeHandler: RouteHandler<R> { get set }

Constructors

  • Initialize explicitly with a window. Defaults to UIApplication.shared.keyWindow.

    Declaration

    Swift

    public init(window: UIWindow?)
  • Defaults to UIApplication.shared.keyWindow.

    Declaration

    Swift

    override public init()

Methods

  • Navigate to a route.

    Note

    Triggers received(unhandledError:) if an error occurs and no completion handler is provided.

    Note

    Will not trigger the transition if the the destination view controller is the same as the source view controller or it’s navigation controller. However, it will call RoutingDelgate(_:).prepareForTransition(to:) either way.

    Declaration

    Swift

    open func navigate(to route: R,
                       animated: Bool = true,
                       completion: ((Error?) -> Void)? = nil)
  • Open a URL to a route.

    Note

    Triggers received(unhandledError:) if an error occurs and no completion handler is provided.

    Note

    Register URL mappings in the RouteType by implementing the static method registerURLs.

    Declaration

    Swift

    @discardableResult
    open func openURL(_ url: URL,
                      animated: Bool = true,
                      completion: ((_ error: Error?) -> Void)? = nil) -> Bool

    Return Value

    A Bool indicating whether the URL was handled or not.

  • Universal links handler.

    Note

    Triggers received(unhandledError:) if an error occurs.

    Note

    Register URL mappings in the RouteType by implementing the static method registerURLs.

    Declaration

    Swift

    open func `continue`(_ userActivity: NSUserActivity) -> Bool

    Return Value

    A Bool indicating whether the NSUserActivity was handled or not.

  • An unhandled error occured during navigate(...) or openURL(...).

    Note

    Uses assertionFailure(_:file:line:). In debug builds, this will throw a runtime exception. In production builds this will fail silently.

    Declaration

    Swift

    open func received(unhandledError error: Error)

RxSwift

  • rx

    Reactive binding for Router.

    Declaration

    Swift

    public var rx: Reactive<XRouter> { get }