Skip to content

Commit b59d281

Browse files
Jager-yoop4checo
authored andcommitted
Fix typos in every DocC-Articles (#1490)
* Fix typos in every DocC-Articles * Update Sources/ComposableArchitecture/Documentation.docc/Articles/DependencyManagement.md * Update Sources/ComposableArchitecture/Documentation.docc/Articles/DependencyManagement.md * Update Sources/ComposableArchitecture/Documentation.docc/Articles/MigratingToTheReducerProtocol.md Co-authored-by: Stephen Celis <[email protected]> (cherry picked from commit c5508de7a071fbe6cd24e238a6b07f23c72c9a11) # Conflicts: # Sources/ComposableArchitecture/Documentation.docc/Articles/Testing.md
1 parent 873097c commit b59d281

File tree

7 files changed

+66
-67
lines changed

7 files changed

+66
-67
lines changed

Sources/ComposableArchitecture/Documentation.docc/Articles/Bindings.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ such communication with your application's store.
1111
### Ad hoc bindings
1212

1313
The simplest tool for creating bindings that communicate with your store is
14-
``ViewStore/binding(get:send:)-65xes``, which is handed two closures: one that describe how to
14+
``ViewStore/binding(get:send:)-65xes``, which is handed two closures: one that describes how to
1515
transform state into the binding's value, and one that describes how to transform the binding's
1616
value into an action that can be fed back into the store.
1717

@@ -197,7 +197,7 @@ struct Settings: ReducerProtocol {
197197
}
198198
```
199199

200-
Each annotated field is directly to bindable to SwiftUI controls, like pickers, toggles, and text
200+
Each annotated field is directly bindable to SwiftUI controls, like pickers, toggles, and text
201201
fields. Notably, the `isLoading` property is _not_ annotated as being bindable, which prevents the
202202
view from mutating this value directly.
203203

Sources/ComposableArchitecture/Documentation.docc/Articles/DependencyManagement.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ to servers, but also seemingly innocuous things such as `UUID` and `Date` initia
1111
schedulers and clocks, can be thought of as dependencies.
1212

1313
By controlling the dependencies our features need to do their job we gain the ability to completely
14-
alter the execution context a features runs in. This means in tests and Xcode previews you can
14+
alter the execution context a feature runs in. This means in tests and Xcode previews you can
1515
provide a mock version of an API client that immediately returns some stubbed data rather than
1616
making a live network request to a server.
1717

@@ -290,7 +290,7 @@ Further, we highly recommend you consider making your `testValue` dependency int
290290
call an "unimplemented" dependency. This is a version of your dependency that performs an `XCTFail`
291291
in each endpoint so that if it is ever invoked in tests it will cause a test failure. This allows
292292
you to be more explicit about what dependencies are actually needed to test a particular user
293-
flow in you feature.
293+
flow in your feature.
294294

295295
For example, suppose you have an API client with endpoints for fetching a list of users or fetching
296296
a particular user by id:
@@ -471,11 +471,11 @@ which can help a feature to seem less intimidating.
471471
## Overriding dependencies
472472

473473
It is possible to change the dependencies for just one particular reducer inside a larger composed
474-
reducer. This can be handy running a feature in a more controlled environment where it may not be
474+
reducer. This can be handy when running a feature in a more controlled environment where it may not be
475475
appropriate to communicate with the outside world.
476476

477-
For example, suppose you want to teach users how to user your feature through on onboarding
478-
experience. In such an experience it may not be appropriate for the users's actions to cause
477+
For example, suppose you want to teach users how to use your feature through an onboarding
478+
experience. In such an experience it may not be appropriate for the user's actions to cause
479479
data to be written to disk, or user defaults to be written, or any number of things. It would be
480480
better to use mock versions of those dependencies so that the user can interact with your feature
481481
in a fully controlled environment.

Sources/ComposableArchitecture/Documentation.docc/Articles/GettingStarted.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ let package = Package(
1414
dependencies: [
1515
.package(
1616
url: "https://github.com/pointfreeco/swift-composable-architecture",
17-
from: "0.41.0"
17+
from: "0.42.0"
1818
),
1919
],
2020
targets: [
@@ -47,7 +47,7 @@ your domain:
4747
so that the store can run the reducer and effects, and you can observe state changes in the
4848
store so that you can update UI.
4949

50-
The benefits of doing this is that you will instantly unlock testability of your feature, and you
50+
The benefits of doing this are that you will instantly unlock testability of your feature, and you
5151
will be able to break large, complex features into smaller domains that can be glued together.
5252

5353
As a basic example, consider a UI that shows a number along with "+" and "−" buttons that increment
@@ -95,7 +95,7 @@ struct Feature: ReducerProtocol {
9595
```
9696

9797
And then we implement the ``ReducerProtocol/reduce(into:action:)-4nzr2`` method which is responsible
98-
for handling the actual logic and behavior for the feature. It describes how to change the current
98+
for handling the actual logic and behavior for the feature. It describes how to change the current
9999
state to the next state, and describes what effects need to be executed. Some actions don't need to
100100
execute effects, and they can return `.none` to represent that:
101101

@@ -244,7 +244,7 @@ class FeatureViewController: UIViewController {
244244
```
245245

246246
Once we are ready to display this view, for example in the app's entry point, we can construct a
247-
store. This can be done by specify the initial state to start the application in, as well as the
247+
store. This can be done by specifying the initial state to start the application in, as well as the
248248
reducer that will power the application:
249249

250250
```swift
@@ -358,7 +358,7 @@ struct MyApp: App {
358358
}
359359
```
360360

361-
But in tests we can use a mock dependency that immediately returns a determinstic, predictable fact:
361+
But in tests we can use a mock dependency that immediately returns a deterministic, predictable fact:
362362

363363
```swift
364364
@MainActor
@@ -478,6 +478,6 @@ await store.receive(.numberFactResponse(.success("0 is a good number Brent"))) {
478478
That is the basics of building and testing a feature in the Composable Architecture. There are
479479
_a lot_ more things to be explored, such as <doc:DependencyManagement>, <doc:Performance>,
480480
<doc:SwiftConcurrency> and more about <doc:Testing>. Also, the [Examples][examples] directory has
481-
a bunch of projects to explore to see more advanced usages.
481+
a bunch of projects to explore to see more advanced usages.
482482

483483
[examples]: https://github.com/pointfreeco/swift-composable-architecture/tree/main/Examples

Sources/ComposableArchitecture/Documentation.docc/Articles/MigratingToTheReducerProtocol.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ allowing you to plug protocol-style reducers into old-style reducers, and vice-v
1212
Although we recommend migrating your code when you have time, the newest version of the library
1313
is still 100% backwards compatible with all previous versions. The ``Reducer`` type is now
1414
"soft" deprecated, which means we consider it deprecated, and it says so in the documentation, but
15-
you will not get any warnings about it. Some time in the future we will officially deprecate it,
15+
you will not get any warnings about it. Sometime in the future, we will officially deprecate it,
1616
and then sometime even later we will remove it so that we can rename the protocol to `Reducer`.
1717

1818
This article outlines a number of strategies you can employ to convert your reducers to the protocol
@@ -89,7 +89,7 @@ struct Feature: ReducerProtocol {
8989
}
9090
```
9191

92-
Once this feature's domain and reducer is converted to the protocol-style you will invariably have
92+
Once this feature's domain and reducer are converted to the protocol-style you will invariably have
9393
compiler errors wherever you were referring to the old types. For example, suppose you have a
9494
parent feature that is currently trying to embed the old-style domain and reducer into its domain
9595
and reducer:
@@ -117,7 +117,7 @@ let parentReducer = Reducer<ParentState, ParentAction, ParentEnvironment>.combin
117117
state: \.feature,
118118
action: /ParentAction.feature,
119119
environment: {
120-
FeatureAEnvironment(date: $0.date)
120+
FeatureEnvironment(date: $0.date)
121121
}
122122
),
123123

@@ -144,7 +144,7 @@ enum ParentAction {
144144

145145
And then the `parentReducer` can be fixed by making use of the helper ``AnyReducer/init(_:)-42p1a``
146146
which aids in converting protocol-style reducers into old-style reducers. It is initialized with a
147-
closure that is passed an environment, which is the one thing protocol-style reducers don't have,
147+
closure that is passed an environment, which is the one thing protocol-style reducers don't have,
148148
and you are to return a protocol-style reducer:
149149

150150
```swift
@@ -174,10 +174,10 @@ leaf node feature to the new ``ReducerProtocol``-style of doing things.
174174
## Composition of features
175175

176176
Some features in your application are an amalgamation of other features. For example, a tab-based
177-
application may have a separate domain and reducer for each tab, and then a app-level domain and
177+
application may have a separate domain and reducer for each tab, and then an app-level domain and
178178
reducer that composes everything together.
179179

180-
Suppose that all of the tab features have already be converted to the protocol-style:
180+
Suppose that all of the tab features have already been converted to the protocol-style:
181181

182182
```swift
183183
struct TabA: ReducerProtocol {
@@ -367,10 +367,10 @@ let parentReducer = Reducer<
367367
Now the question is, how do we migrate `parentReducer` to a protocol conformance?
368368

369369
This gives us an opportunity to improve the correctness of this code. It turns out there is a gotcha
370-
with the `optional` operator: it must be run _before_ the parent logic runs. If it is not, then it
371-
is possible for a child action to come into the system, the parent observe the action and decide to
372-
`nil` out the child state, and then the child reducer will not get a chance to react to the action.
373-
This can cause subtle bugs, and so we have documentation advising you to order things the correct
370+
with the `optional` operator: it must be run _before_ the parent logic runs. If it is not, then it
371+
is possible for a child action to come into the system, the parent observes the action and decides to
372+
`nil` out the child state, and then the child reducer will not get a chance to react to the action.
373+
This can cause subtle bugs, and so we have documentation advising you to order things the correct
374374
way, and if we detect a child action while state is `nil` we display a runtime warning.
375375

376376
A `Parent` reducer conformances can be made by implementing the

Sources/ComposableArchitecture/Documentation.docc/Articles/Performance.md

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ struct AppView: View {
195195
}
196196
```
197197

198-
This gives you maximum flexibilty in the future for adding new fields to `ViewState` without making
198+
This gives you maximum flexibility in the future for adding new fields to `ViewState` without making
199199
your view convoluated.
200200

201201
This technique for reducing view re-computations is most effective towards the root of your app
@@ -209,8 +209,8 @@ store.
209209
### Sharing logic with actions
210210

211211
There is a common pattern of using actions to share logic across multiple parts of a reducer.
212-
This is an ineffecient way to share logic. Sending actions is not as lightweight of an operation
213-
as, say, caling a method on a class. Actions travel through multiple layers of an application, and
212+
This is an inefficient way to share logic. Sending actions is not as lightweight of an operation
213+
as, say, calling a method on a class. Actions travel through multiple layers of an application, and
214214
at each layer a reducer can intercept and reinterpret the action.
215215

216216
It is far better to share logic via simple methods on your ``ReducerProtocol`` conformance.
@@ -263,8 +263,7 @@ be if only a single action was sent.
263263
Besides just performance concerns, there are two other reasons why you should not follow this
264264
pattern. First, this style of sharing logic is not very flexible. Because the shared logic is
265265
relegated to a separate action it must always be run after the initial logic. But what if
266-
instead you need to run some shared logic _before_ the core logic? This style cannot accomodate
267-
for that.
266+
instead you need to run some shared logic _before_ the core logic? This style cannot accommodate that.
268267

269268
Second, this style of sharing logic also muddies tests. When you send a user action you have to
270269
further assert on receiving the shared action and assert on how state changed. This bloats tests
@@ -301,7 +300,7 @@ So, we do not recommend sharing logic in a reducer by having dedicated actions f
301300
and executing synchronous effects.
302301

303302
Instead, we recommend sharing logic with methods defined in your feature's reducer. The method has
304-
full access to all depedencies, it can take an `inout State` if it needs to make mutations to
303+
full access to all dependencies, it can take an `inout State` if it needs to make mutations to
305304
state, and it can return an `Effect<Action, Never>` if it needs to execute effects.
306305

307306
The above example can be refactored like so:
@@ -430,7 +429,7 @@ calls that one does with classes, such as `ObservableObject` conformances. When
430429
into the system there are multiple layers of features that can intercept and interpret it, and
431430
the resulting state changes can reverberate throughout the entire application.
432431

433-
Because of this, sending actions do come with a cost. You should aim to only send "significant"
432+
Because of this, sending actions does come with a cost. You should aim to only send "significant"
434433
actions into the system, that is, actions that cause the execution of important logic and effects
435434
for your application. High-frequency actions, such as sending dozens of actions per second,
436435
should be avoided unless your application truly needs that volume of actions in order to implement
@@ -486,7 +485,7 @@ incurring unnecessary costs for sending actions.
486485

487486
In very large SwiftUI applications you may experience degraded compiler performance causing long
488487
compile times, and possibly even compiler failures due to "complex expressions." The
489-
``WithViewStore`` helpers that comes with the library can exacerbate that problem for very complex
488+
``WithViewStore`` helpers that come with the library can exacerbate that problem for very complex
490489
views. If you are running into issues using ``WithViewStore`` you can make a small change to your
491490
view to use an `@ObservedObject` directly.
492491

Sources/ComposableArchitecture/Documentation.docc/Articles/SwiftConcurrency.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ return .task { [count = state.count] in
7171
### Accessing dependencies in an effect
7272

7373
In the Composable Architecture, one provides dependencies to a reducer so that it can interact with
74-
the outside world in a determinstic and controlled manner. Those dependencies can be used from
74+
the outside world in a deterministic and controlled manner. Those dependencies can be used from
7575
asynchronous and concurrent contexts, and so must be `Sendable`.
7676

7777
If your dependency is not sendable, you will be notified at the time of registering it with the
@@ -101,5 +101,5 @@ struct FactClient {
101101
}
102102
```
103103

104-
This will restrict the kinds of closures that can be used when construct `FactClient` values, thus
104+
This will restrict the kinds of closures that can be used when constructing `FactClient` values, thus
105105
making the entire `FactClient` sendable itself.

Sources/ComposableArchitecture/Documentation.docc/Articles/Testing.md

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -21,35 +21,35 @@ then assert on how it changed after, like this:
2121

2222
```swift
2323
struct Feature: ReducerProtocol {
24-
struct State: Equatable { var count = 0 }
25-
enum Action { case incrementButtonTapped, decrementButtonTapped }
24+
struct State: Equatable { var count = 0 }
25+
enum Action { case incrementButtonTapped, decrementButtonTapped }
2626

2727
func reduce(into state: inout State, action: Action) -> Effect<Action, Never> {
28-
switch action {
29-
case .incrementButtonTapped:
30-
state.count += 1
31-
return .none
32-
case .decrementButtonTapped:
33-
state.count -= 1
34-
return .none
28+
switch action {
29+
case .incrementButtonTapped:
30+
state.count += 1
31+
return .none
32+
case .decrementButtonTapped:
33+
state.count -= 1
34+
return .none
35+
}
3536
}
3637
}
37-
}
3838

3939
func testBasics() {
4040
let feature = Feature()
4141
var currentState = Feature.State(count: 0)
4242
_ = feature.reduce(into: &currentState, action: .incrementButtonTapped)
43-
XCTAssertEqual(
44-
currentState,
45-
State(count: 1)
46-
)
43+
XCTAssertEqual(
44+
currentState,
45+
State(count: 1)
46+
)
4747

4848
_ = feature.reduce(into: &currentState, action: .decrementButtonTapped)
49-
XCTAssertEqual(
50-
currentState,
51-
State(count: 0)
52-
)
49+
XCTAssertEqual(
50+
currentState,
51+
State(count: 0)
52+
)
5353
}
5454
```
5555

@@ -182,34 +182,34 @@ Effects form a major part of a feature's logic. They can perform network request
182182
services, load and save data to disk, start and stop timers, interact with Apple frameworks (Core
183183
Location, Core Motion, Speech Recognition, etc.), and more.
184184

185-
As a simple example, suppose we have a feature with a button such that when you tap it it starts
185+
As a simple example, suppose we have a feature with a button such that when you tap it, it starts
186186
a timer that counts up until you reach 5, and then stops. This can be accomplished using the
187-
``Effect/run(priority:operation:catch:file:fileID:line:)`` helper, which provides you an
187+
``Effect/run(priority:operation:catch:file:fileID:line:)`` helper, which provides you with an
188188
asynchronous context to operate in and can send multiple actions back into the system:
189189

190190
```swift
191191
struct Feature: ReducerProtocol {
192-
struct State: Equatable { var count = 0 }
193-
enum Action { case startTimerButtonTapped, timerTick }
192+
struct State: Equatable { var count = 0 }
193+
enum Action { case startTimerButtonTapped, timerTick }
194194
enum TimerID {}
195195

196196
func reduce(into state: inout State, action: Action) -> Effect<Action, Never> {
197-
switch action {
198-
case .startTimerButtonTapped:
199-
state.count = 0
200-
return .run { send in
201-
for _ in 1...5 {
197+
switch action {
198+
case .startTimerButtonTapped:
199+
state.count = 0
200+
return .run { send in
201+
for _ in 1...5 {
202202
try await Task.sleep(for: .seconds(1))
203-
await send(.timerTick)
203+
await send(.timerTick)
204+
}
204205
}
205-
}
206206

207-
case .timerTick:
208-
state.count += 1
209-
return .none
207+
case .timerTick:
208+
state.count += 1
209+
return .none
210+
}
210211
}
211212
}
212-
}
213213
```
214214

215215
To test this we can start off similar to how we did in the [previous section][Testing-state-changes]
@@ -304,7 +304,7 @@ await store.receive(.timerTick, timeout: .seconds(2)) {
304304
Now the full test suite passes, and we have exhaustively proven how effects are executed in this
305305
feature. If in the future we tweak the logic of the effect, like say have it emit 10 times instead
306306
of 5, then we will immediately get a test failure letting us know that we have not properly
307-
asserted on how the features evolves over time.
307+
asserted on how the features evolve over time.
308308

309309
However, there is something not ideal about how this feature is structured, and that is the fact
310310
that we are doing actual, uncontrolled time-based asynchrony in the effect:

0 commit comments

Comments
 (0)