Skip to content

Commit 12b028e

Browse files
authored
Remove broken link (#1523)
* Remove broken link Fix #1522. * Update DependencyManagement.md
1 parent 414e88d commit 12b028e

File tree

1 file changed

+20
-28
lines changed

1 file changed

+20
-28
lines changed

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

Lines changed: 20 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,7 @@ This is why controlling dependencies is important. It allows us to substitute a
9696
is deterministic in tests, such as one that simply increments by 1 every time it is invoked.
9797

9898
The library comes with a controlled UUID generator and can be accessed by using the
99-
[`@Dependency`][dependency-property-wrapper-docs] property wrapper to add a dependency to the
100-
`Todos` reducer:
99+
`@Dependency` property wrapper to add a dependency to the `Todos` reducer:
101100

102101
```swift
103102
struct Todos: ReducerProtocol {
@@ -145,8 +144,7 @@ control dependencies that interact with outside systems.
145144
## Using library dependencies
146145

147146
The library comes with many common dependencies that can be used in a controllable manner, such as
148-
date generators, schedulers, random number generators, UUID generators, and more. A full
149-
list can be seen in the documentation for [`DependencyValues`][dependency-values-docs].
147+
date generators, schedulers, random number generators, UUID generators, and more.
150148

151149
For example, suppose you have a feature that needs access to a date initializer, the main queue
152150
for time-based asynchrony, and a UUID initializer. All 3 dependencies can be added to your feature's
@@ -191,13 +189,12 @@ func testTodos() async {
191189

192190
Although the library comes with many controllable dependencies out of the box, there are still
193191
times when you want to register your own dependencies with the library so that you can use the
194-
[`@Dependency`][dependency-property-wrapper-docs] property wrapper. Doing this is quite similar to
195-
registering an [environment value][environment-values-docs] in SwiftUI.
192+
`@Dependency` property wrapper. Doing this is quite similar to registering an
193+
[environment value][environment-values-docs] in SwiftUI.
196194

197-
First you create a type that conforms to the [`DependencyKey`][dependency-key-docs]
198-
protocol. The minimum implementation you must provide is a `liveValue`, which is the value used
199-
when running the app in a simulator or on device, and so it's appropriate for it to actually make
200-
network requests to an external server:
195+
First you create a type that conforms to the `DependencyKey` protocol. The minimum implementation
196+
you must provide is a `liveValue`, which is the value used when running the app in a simulator or
197+
on device, and so it's appropriate for it to actually make network requests to an external server:
201198

202199
```swift
203200
private enum APIClientKey: DependencyKey {
@@ -211,8 +208,8 @@ will be used while running features in an Xcode preview. You don't need to worry
211208
values when you are just getting started, and instead can
212209
[add them later](#Live-preview-and-test-dependencies).
213210

214-
Finally, an extension must be made to [`DependencyValues`][dependency-values-docs] to expose a
215-
computed property for the dependency:
211+
Finally, an extension must be made to `DependencyValues` to expose a computed property for the
212+
dependency:
216213

217214
```swift
218215
extension DependencyValues {
@@ -224,7 +221,7 @@ extension DependencyValues {
224221
```
225222

226223
With those few steps completed you can instantly access your API client dependency from any
227-
feature's reducer by using the [`@Dependency`][dependency-property-wrapper-docs] property wrapper:
224+
feature's reducer by using the `@Dependency` property wrapper:
228225

229226
```swift
230227
struct Todos: ReducerProtocol {
@@ -274,11 +271,11 @@ That can save a little bit of boilerplate.
274271

275272
## Live, preview and test dependencies
276273

277-
In the previous section we showed that to conform to [`DependencyKey`][dependency-key-docs] you must
278-
provide _at least_ a `liveValue`, which is the default version of the dependency that is used when
279-
running on a device or simulator. The `DependencyKey` protocol inherits from a base protocol,
280-
[`TestDependencyKey`][test-dependency-key-docs], which has 2 other requirements, `testValue`
281-
and `previewValue`. Both are optional and delegate to `liveValue` if not implemented.
274+
In the previous section we showed that to conform to `DependencyKey` you must provide _at least_
275+
a `liveValue`, which is the default version of the dependency that is used when running on a
276+
device or simulator. The `DependencyKey` protocol inherits from a base protocol,
277+
`TestDependencyKey`, which has 2 other requirements, `testValue` and `previewValue`. Both are
278+
optional and delegate to `liveValue` if not implemented.
282279

283280
If you implement a static `testValue` property on your key, that value will be used when running
284281
your feature in a ``TestStore``. This is a great opportunity to supply a mocked version of the
@@ -339,12 +336,11 @@ extension APIClient: TestDependencyKey {
339336
}
340337
```
341338

342-
The other requirement of [`TestDependencyKey`][test-dependency-key-docs] is `previewValue`, and if
343-
this value is implemented it will be used whenever your feature is run in an Xcode preview.
344-
Previews are similar to tests in that you usually do not want to interact with the outside world,
345-
such as making network requests. In fact, many of Apple's frameworks do not work in previews, such
346-
as CoreLocation, and so it will be hard to interact with your feature in previews if it touches
347-
those frameworks.
339+
The other requirement of `TestDependencyKey` is `previewValue`, and if this value is implemented
340+
it will be used whenever your feature is run in an Xcode preview. Previews are similar to tests in
341+
that you usually do not want to interact with the outside world, such as making network requests.
342+
In fact, many of Apple's frameworks do not work in previews, such as Core Location, and so it will
343+
be hard to interact with your feature in previews if it touches those frameworks.
348344

349345
However, previews are dissimilar to tests in that it's fine for dependencies to return some mock
350346
data. There's no need to deal with "unimplemented" clients for proving which dependencies are
@@ -499,10 +495,6 @@ struct Onboarding: ReducerProtocol {
499495
This will cause the `Feature` reducer to use a mock user defaults and database dependency, as well
500496
as any reducer `Feature` uses under the hood, _and_ any effects produced by `Feature`.
501497

502-
[dependency-values-docs]: https://pointfreeco.github.io/swift-composable-architecture/main/documentation/dependencies/dependencyvalues
503498
[swift-identified-collections]: https://github.com/pointfreeco/swift-identified-collections
504-
[dependency-property-wrapper-docs]: https://pointfreeco.github.io/swift-composable-architecture/main/documentation/dependencies/dependency
505499
[environment-values-docs]: https://developer.apple.com/documentation/swiftui/environmentvalues
506-
[dependency-key-docs]: https://pointfreeco.github.io/swift-composable-architecture/main/documentation/dependencies/dependencykey
507-
[test-dependency-key-docs]: https://pointfreeco.github.io/swift-composable-architecture/main/documentation/dependencies/testdependencykey
508500
[xctest-dynamic-overlay-gh]: http://github.com/pointfreeco/xctest-dynamic-overlay

0 commit comments

Comments
 (0)