@@ -155,15 +155,15 @@ Fortunately, Navigator supports checkpoints; named points in the navigation stac
155155
156156Checkpoints are easy to define and use. Let's create one called "home" and then use it.
157157``` swift
158- extension NavigationCheckpoint {
159- public static let home: NavigationCheckpoint = " home "
158+ struct KnownCheckpoints : NavigationCheckpoints {
159+ public static var home: NavigationCheckpoint { checkpoint () }
160160}
161161
162162struct RootHomeView : View {
163163 var body: some View {
164164 ManagedNavigationStack (scene : " home" ) {
165165 HomeContentView (title : " Home Navigation" )
166- .navigationCheckpoint (.home )
166+ .navigationCheckpoint (KnownCheckpoints .home )
167167 .navigationDestination (HomeDestinations.self )
168168 }
169169 }
@@ -172,22 +172,27 @@ struct RootHomeView: View {
172172Once defined, they're easy to use.
173173``` swift
174174Button (" Return To Checkpoint Home" ) {
175- navigator.returnToCheckpoint (.home )
175+ navigator.returnToCheckpoint (KnownCheckpoints .home )
176176}
177- .disabled (! navigator.canReturnToCheckpoint (.home ))
177+ .disabled (! navigator.canReturnToCheckpoint (KnownCheckpoints .home ))
178178```
179179When fired, checkpoints will dismiss any presented screens and pop any pushed views to return * exactly* to the point desired.
180180
181181Checkpoints can also be used to return values to a caller.
182182``` swift
183- // Define a checkpoint with a value handler.
184- .navigationCheckpoint (.settings ) { (result : Int ) in
183+ // Define a checkpoint with an Int value handler.
184+ extension KnownCheckpoints {
185+ public static var settings: NavigationCheckpoint<Int > { checkpoint () }
186+ }
187+
188+ // Establish the checkpoint and handler in our view
189+ .navigationCheckpoint (KnownCheckpoints.settings ) { result in
185190 returnValue = result
186191}
187192
188193// Return, passing a value.
189194Button (" Return to Settings Checkpoint Passing Value 5" ) {
190- navigator.returnToCheckpoint (.settings , value : 5 )
195+ navigator.returnToCheckpoint (KnownCheckpoints .settings , value : 5 )
191196}
192197```
193198Checkpoints are a powerful tool. Use them.
0 commit comments