RoutableWithConfiguration

public protocol RoutableWithConfiguration: Routable

A RoutableWithConfiguration is a ViewController that takes active part to the execution of a navigation action.

If a screen listScreen needs to present addItemScreen, the ViewController that is handling listScreen must conform to the RoutableWithConfiguration protocol.

When a Show("addItemScreen") action is dispatched, the Navigator will capture the action and will start finding a RoutableWithConfiguration in the active hierarchy that can handle the action. If the navigationConfiguration of listScreen will match the NavigationRequest of .show(addItemScreen) than the Navigator will execute the relative NavigationInstruction where you can configure the ViewController to present.

There are others NavigationRequests and NavigationInstructions that can be used to define the navigation structure of the app.

In case you need more control, you can always implement the Routable protocol yourself and have fine grained control of the implementation of the navigation. In fact, a RoutableWithConfiguration and its navigationConfiguration are used behind the scenes to implement the Routable protocol for you.

   extension ListViewController: RoutableWithConfiguration {

     // needed by the `Routable` protocol
     // to identify this ViewController in the hierarchy
     var routeIdentifier: RouteElementIdentifier {
       return "listScreen"
     }

     // the `NavigationRequest`s that this ViewController is handling
     // with the `NavigationInstruction` to execute
     var navigationConfiguration: [NavigationRequest: NavigationInstruction] {
       return [
         .show("addItemScreen"): .presentModally({ [unowned self] _ in
           let vc = AddItemViewController(store: self.store)
           return vc
         })
       ]
   }