Skip to content

Commit

Permalink
Adds assertion to catch going back more than is possible
Browse files Browse the repository at this point in the history
johnpatrickmorgan committed May 23, 2022
1 parent be3c288 commit e25db36
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion FlowStacks.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|

s.name = 'FlowStacks'
s.version = '0.2.0'
s.version = '0.2.1'
s.summary = 'Hoist navigation state into a coordinator in SwiftUI.'

s.description = <<-DESC
4 changes: 4 additions & 0 deletions Sources/FlowStacks/RoutableCollection+utilities.swift
Original file line number Diff line number Diff line change
@@ -62,6 +62,10 @@ public extension RoutableCollection where Element: RouteProtocol {
/// Goes back a given number of screens off the stack
/// - Parameter count: The number of screens to go back. Defaults to 1.
mutating func goBack(_ count: Int = 1) {
assert(
self.count - count >= 0,
"Can't go back\(count == 1 ? "" : " \(count) screens") - the screen count is \(self.count)"
)
guard self.count - count >= 0 else { return }
removeLast(count)
}

0 comments on commit e25db36

Please sign in to comment.