From e45570982dbbd3a02cc469f062a2edd138178ac4 Mon Sep 17 00:00:00 2001 From: Joe Masilotti Date: Wed, 15 Nov 2023 10:27:57 -0800 Subject: [PATCH] Expose a route function with a VisitProposal param --- Source/Turbo Navigator/TurboNavigator.swift | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Source/Turbo Navigator/TurboNavigator.swift b/Source/Turbo Navigator/TurboNavigator.swift index e5198a0..e4fb46a 100644 --- a/Source/Turbo Navigator/TurboNavigator.swift +++ b/Source/Turbo Navigator/TurboNavigator.swift @@ -56,14 +56,20 @@ public class TurboNavigator { } /// Transforms `URL` -> `VisitProposal` -> `UIViewController`. - /// Given the `VisitProposal`'s properties, push or present this view controller. + /// Convenience function to routing a proposal directly. /// - /// - Parameter url: the URL to visit. + /// - Parameter url: the URL to visit public func route(_ url: URL) { let options = VisitOptions(action: .advance, response: nil) let properties = session.pathConfiguration?.properties(for: url) ?? PathProperties() - let proposal = VisitProposal(url: url, options: options, properties: properties) + route(VisitProposal(url: url, options: options, properties: properties)) + } + /// Transforms `VisitProposal` -> `UIViewController` + /// Given the `VisitProposal`'s properties, push or present this view controller. + /// + /// - Parameter proposal: the proposal to visit + public func route(_ proposal: VisitProposal) { guard let controller = controller(for: proposal) else { return } hierarchyController.route(controller: controller, proposal: proposal) }