File tree Expand file tree Collapse file tree 3 files changed +10
-8
lines changed
Expand file tree Collapse file tree 3 files changed +10
-8
lines changed Original file line number Diff line number Diff line change @@ -46,11 +46,6 @@ let package = Package(
4646 name: " GoodReactorTests " ,
4747 dependencies: [ " GoodReactor " ] ,
4848 swiftSettings: [ . swiftLanguageMode( . v6) ]
49- ) ,
50- . testTarget(
51- name: " GoodCoordinatorTests " ,
52- dependencies: [ " LegacyReactor " ] ,
53- swiftSettings: [ . swiftLanguageMode( . v6) ]
5449 )
5550 ]
5651)
Original file line number Diff line number Diff line change @@ -47,14 +47,14 @@ struct EventTaskCounter: Sendable {
4747 /// Increments task counter for provided event
4848 /// - Parameter identifier: Event starting a new task
4949 mutating func newTask( eventId identifier: EventIdentifier ) {
50- events [ identifier] = ( events [ identifier] ?? 0 ) + 1
50+ events [ identifier] = events [ identifier, default : 0 ] + 1
5151 }
5252
5353 /// Decrements task counter for provided event
5454 /// - Parameter identifier: Event stopping the task
5555 /// - Returns: Number of remaining tasks
5656 mutating func stopTask( eventId identifier: EventIdentifier ) -> Int {
57- let taskCount = events [ identifier] ?? 0
57+ let taskCount = events [ identifier, default : 0 ]
5858 let newTaskCount = taskCount - 1
5959
6060 events [ identifier] = newTaskCount
Original file line number Diff line number Diff line change 77
88import Observation
99
10+ /// Stub is a ``Reactor`` implementation adjusted for use in Xcode previews
11+ /// to mock different states of the UI. Stub resolves the state at initialization and
12+ /// supports small changes to state in its `reducer`.
1013@available ( iOS 17 . 0 , macOS 14 . 0 , * )
1114@Observable public final class Stub < R: Reactor > : Reactor {
1215
@@ -29,7 +32,11 @@ import Observation
2932 public func reduce( state: inout R . State , event: Event ) {
3033 reducer ? ( & state, event)
3134 }
32-
35+
36+ /// Initializes a Stub ``Reactor`` with state and a simple reducer.
37+ /// - Parameters:
38+ /// - supplier: Closure supplying initial mocked state
39+ /// - reducer: Closure reducing small changes to mocked state
3340 public init (
3441 supplier: @escaping ( ( ) -> ( R . State ) ) ,
3542 reducer: ( ( inout R . State , Event ) -> ( ) ) ? = nil
You can’t perform that action at this time.
0 commit comments