Basically all you need is to call configureRoutes
method of the viewController, it accepts routing publisher and routeConfigurations, your code may look somewhat like this:
final class MyViewController: UIViewController {
// ...
func bindViewModel() {
configureRoutes(
for viewModel.publisher(for: \.state.route),
routes: [
// Provide mapping from route to controller
.associate(makeDetailsController, with: .details)
],
onDismiss: {
// Update state on dismiss
viewModel.send(.dismiss)
}
).store(in: &cancellables)
}
}
You can add CombineNavigation to an Xcode project by adding it as a package dependency.
- From the File menu, select Swift Packages › Add Package Dependency…
- Enter
"https://github.com/capturecontext/combine-cocoa-navigation.git"
into the package repository URL text field - Choose products you need to link them to your project.
If you use SwiftPM for your project, you can add CombineNavigation to your package file.
.package(
url: "https://github.com/capturecontext/combine-cocoa-navigation.git",
.upToNextMinor(from: "0.2.0")
)
Do not forget about target dependencies:
.product(
name: "CombineNavigation",
package: "combine-cocoa-navigation"
)
## License
This package is released under the MIT license. See [LICENSE](./LICENSE) for details.