Skip to content

Commit 1ca1e16

Browse files
committed
wip
1 parent f3e2194 commit 1ca1e16

File tree

3 files changed

+6
-25
lines changed

3 files changed

+6
-25
lines changed

Sources/ComposableArchitecture/Dependencies/Dismiss.swift

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -69,22 +69,7 @@ public struct DismissEffect: Sendable {
6969
fileID: StaticString = #fileID,
7070
line: UInt = #line
7171
) async {
72-
guard let dismiss = self.dismiss
73-
else {
74-
runtimeWarn(
75-
"""
76-
A reducer requested dismissal at "\(fileID):\(line)", but couldn't be dismissed. …
77-
78-
This is generally considered an application logic error, and can happen when a reducer \
79-
assumes it runs in a presentation context. If a reducer can run at both the root level \
80-
of an application, as well as in a presentation destination, use \
81-
@Dependency(\\.isPresented) to determine if the reducer is being presented before calling \
82-
@Dependency(\\.dismiss).
83-
"""
84-
)
85-
return
86-
}
87-
dismiss()
72+
await self.callAsFunction(animation: nil, fileID: fileID, line: line)
8873
}
8974

9075
@MainActor

Sources/ComposableArchitecture/Reducer/Reducers/PresentationReducer.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ extension ReducerProtocol {
198198
/// * When a ``PresentationAction/dismiss`` action is sent, it runs the parent feature
199199
/// before the child state is `nil`'d out. This gives the parent feature an opportunity to
200200
/// inspect the child state one last time before the state is cleared.
201-
/// * When a ``PresentationAction/presented(_:)`` action is sent it runs runs the
201+
/// * When a ``PresentationAction/presented(_:)`` action is sent it runs the
202202
/// child first, and then the parent. If the order was reversed, then it would be possible
203203
/// for the parent feature to `nil` out the child state, in which case the child feature
204204
/// would not be able to react to that action. That can cause subtle bugs.

Sources/ComposableArchitecture/Reducer/Reducers/StackReducer.swift

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ import OrderedCollections
99
///
1010
/// See the dedicated article on <doc:Navigation> for more information on the library's navigation
1111
/// tools, and in particular see <doc:StackBasedNavigation> for information on modeling navigation
12-
/// using ``StackState`` for navigation stacks.
12+
/// using ``StackState`` for navigation stacks. Also see
13+
/// <doc:StackBasedNavigation#StackState-vs-NavigationPath> to understand how ``StackState``
14+
/// compares to SwiftUI's `NavigationPath` type.
1315
public struct StackState<Element> {
1416
var _dictionary: OrderedDictionary<StackElementID, Element>
1517
fileprivate var _mounted: Set<StackElementID> = []
@@ -78,19 +80,13 @@ public struct StackState<Element> {
7880

7981
extension StackState: RandomAccessCollection, RangeReplaceableCollection {
8082
public var startIndex: Int { self._dictionary.keys.startIndex }
81-
8283
public var endIndex: Int { self._dictionary.keys.endIndex }
83-
8484
public func index(after i: Int) -> Int { self._dictionary.keys.index(after: i) }
85-
8685
public func index(before i: Int) -> Int { self._dictionary.keys.index(before: i) }
87-
8886
public subscript(position: Int) -> Element { self._dictionary.values[position] }
89-
9087
public init() {
9188
self._dictionary = [:]
9289
}
93-
9490
public mutating func replaceSubrange<C: Collection>(_ subrange: Range<Int>, with newElements: C)
9591
where C.Element == Element {
9692
for id in self.ids[subrange] {
@@ -210,7 +206,7 @@ extension ReducerProtocol {
210206
/// ergonomic and enforce correctness:
211207
///
212208
/// * It forces a specific order of operations for the child and parent features:
213-
/// * When a ``StackAction/element(id:action:)`` action is sent it runs runs the
209+
/// * When a ``StackAction/element(id:action:)`` action is sent it runs the
214210
/// child first, and then the parent. If the order was reversed, then it would be possible
215211
/// for the parent feature to `nil` out the child state, in which case the child feature
216212
/// would not be able to react to that action. That can cause subtle bugs.

0 commit comments

Comments
 (0)