Skip to content

Commit 6e52bf1

Browse files
committed
Cleanup (#1107)
1 parent d6c66a6 commit 6e52bf1

File tree

3 files changed

+16
-15
lines changed

3 files changed

+16
-15
lines changed

Sources/ComposableArchitecture/Effect.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,7 @@ extension Effect {
170170
/// Turns any `SignalProducer` into an ``Effect`` that cannot fail by wrapping its output and failure into
171171
/// result and then applying passed in function to it.
172172
///
173-
/// This is a convenience operator for writing ``Effect/catchToEffect()`` followed by a
174-
/// ``Effect/map(_:)``.
173+
/// This is a convenience operator for writing ``Effect/catchToEffect()`` followed by `map`.
175174
///
176175
/// ```swift
177176
/// case .buttonTapped:

Sources/ComposableArchitecture/Store.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,7 @@ public final class Store<State, Action> {
245245
/// ```
246246
///
247247
/// The login view holds onto a store of this domain:
248+
///
248249
/// ```swift
249250
/// struct LoginView: View {
250251
/// let store: Store<LoginState, LoginAction>
@@ -361,6 +362,8 @@ public final class Store<State, Action> {
361362

362363
/// Scopes the store to one that exposes local state.
363364
///
365+
/// A version of ``scope(state:action:)`` that leaves the action type unchanged.
366+
///
364367
/// - Parameter toLocalState: A function that transforms `State` into `LocalState`.
365368
/// - Returns: A new store with its domain (state and action) transformed.
366369
public func scope<LocalState>(

Sources/ComposableArchitecture/TestSupport/TestStore.swift

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
/// struct CounterState {
4444
/// var count = 0
4545
/// }
46-
///
4746
/// enum CounterAction: Equatable {
4847
/// case decrementButtonTapped
4948
/// case incrementButtonTapped
@@ -68,12 +67,12 @@
6867
/// class CounterTests: XCTestCase {
6968
/// func testCounter() {
7069
/// let store = TestStore(
71-
/// initialState: .init(count: 0), // GIVEN counter state of 0
70+
/// initialState: .init(count: 0), // Given a counter state of 0
7271
/// reducer: counterReducer,
7372
/// environment: ()
7473
/// )
75-
/// store.send(.incrementButtonTapped) { // WHEN the increment button is tapped
76-
/// $0.count = 1 // THEN the count should be 1
74+
/// store.send(.incrementButtonTapped) { // When the increment button is tapped
75+
/// $0.count = 1 // Then the count should be 1
7776
/// }
7877
/// }
7978
/// }
@@ -84,8 +83,8 @@
8483
/// to match the state after the action was sent. In this case the `count` field changes to `1`.
8584
///
8685
/// For a more complex example, consider the following bare-bones search feature that uses the
87-
/// ``Effect/debounce(id:for:scheduler:)`` operator to wait for the user to stop typing
88-
/// before making a network request:
86+
/// ``Effect/debounce(id:for:scheduler:)-76yye`` operator to wait for the user to stop
87+
/// typing before making a network request:
8988
///
9089
/// ```swift
9190
/// struct SearchState: Equatable {
@@ -176,7 +175,7 @@
176175
private var inFlightEffects: Set<LongLivingEffect> = []
177176
var receivedActions: [(action: Action, state: State)] = []
178177
private let reducer: Reducer<State, Action, Environment>
179-
private var snapshotState: State
178+
private var state: State
180179
private var store: Store<State, TestAction>!
181180
private let toLocalState: (State) -> LocalState
182181

@@ -194,7 +193,7 @@
194193
self.fromLocalAction = fromLocalAction
195194
self.line = line
196195
self.reducer = reducer
197-
self.snapshotState = initialState
196+
self.state = initialState
198197
self.toLocalState = toLocalState
199198

200199
self.store = Store(
@@ -204,7 +203,7 @@
204203
switch action.origin {
205204
case let .send(localAction):
206205
effects = self.reducer.run(&state, self.fromLocalAction(localAction), self.environment)
207-
self.snapshotState = state
206+
self.state = state
208207

209208
case let .receive(action):
210209
effects = self.reducer.run(&state, action, self.environment)
@@ -352,7 +351,7 @@
352351
file: file, line: line
353352
)
354353
}
355-
var expectedState = self.toLocalState(self.snapshotState)
354+
var expectedState = self.toLocalState(self.state)
356355
self.store.send(.init(origin: .send(action), file: file, line: line))
357356
do {
358357
try self.expectedStateShouldChange(
@@ -366,7 +365,7 @@
366365
}
367366
self.expectedStateShouldMatch(
368367
expected: expectedState,
369-
actual: self.toLocalState(self.snapshotState),
368+
actual: self.toLocalState(self.state),
370369
file: file,
371370
line: line
372371
)
@@ -465,7 +464,7 @@
465464
file: file, line: line
466465
)
467466
}
468-
var expectedState = self.toLocalState(self.snapshotState)
467+
var expectedState = self.toLocalState(self.state)
469468
do {
470469
try self.expectedStateShouldChange(
471470
expected: &expectedState,
@@ -482,7 +481,7 @@
482481
file: file,
483482
line: line
484483
)
485-
snapshotState = state
484+
self.state = state
486485
if "\(self.file)" == "\(file)" {
487486
self.line = line
488487
}

0 commit comments

Comments
 (0)