Skip to content

Navigating through different levels #19

Answered by mbrandonw
DavidKmn asked this question in Q&A
Discussion options

You must be logged in to vote

This is definitely possible. You'll want to nest your routes:

enum AppRoute {
    case discover
    case home(HomeRoute) ⬅️
    case settings
}
enum HomeRoute {
    case similarProducts
    case info(InfoRoute) ⬅️
}
enum InfoRoute {
    case termsAndConditions
    case helpCentre(helpTicketId: Int)
}

And then you can nest your routers:

let infoRouter = OneOf {
  ...
}

let homeRouter = OneOf {
  Route(HomeRoute.info) {
    Path { "info" }
    infoRouter
  }

  ...
}

let appRouter = OneOf {
  Route(AppRoute.home) {
    Path { "home" }
    homeRouter
  }

  ...
}

And that allows you to put the route enum and router into a feature module.

We demonstrated this in detail in the 2nd part of ou…

Replies: 1 comment 7 replies

Comment options

You must be logged in to vote
7 replies
@DavidKmn
Comment options

@mbrandonw
Comment options

@lukeredpath
Comment options

@DavidKmn
Comment options

@lukeredpath
Comment options

Answer selected by DavidKmn
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants