File tree Expand file tree Collapse file tree 1 file changed +12
-9
lines changed Expand file tree Collapse file tree 1 file changed +12
-9
lines changed Original file line number Diff line number Diff line change @@ -492,15 +492,18 @@ extension DependencyValues {
492
492
```
493
493
494
494
With that little bit of upfront work done you can instantly start making use of the dependency in
495
- any feature:
496
-
497
- ``` swift
498
- struct Feature : ReducerProtocol {
499
- struct State { … }
500
- enum Action { … }
501
- @Dependency (\.numberFact ) var numberFact
502
- …
503
- }
495
+ any feature by using the ` @Dependency ` property wrapper:
496
+
497
+ ``` diff
498
+ struct Feature: ReducerProtocol {
499
+ - let numberFact: (Int) async throws -> String
500
+ + @Dependency(\.numberFact) var numberFact
501
+
502
+ …
503
+
504
+ - try await self.numberFact(count)
505
+ + try await self.numberFact.fetch(count)
506
+ }
504
507
```
505
508
506
509
This code works exactly as it did before, but you no longer have to explicitly pass the dependency
You can’t perform that action at this time.
0 commit comments