Skip to content

Commit f94a186

Browse files
Added reminder to use the .fetch() in the reduce() when using NumberF… (#1962)
* Added reminder to use the .fetch() in the reduce() when using NumberFactClient * wip --------- Co-authored-by: Brandon Williams <[email protected]>
1 parent ba06026 commit f94a186

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

README.md

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -492,15 +492,18 @@ extension DependencyValues {
492492
```
493493

494494
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+
}
504507
```
505508

506509
This code works exactly as it did before, but you no longer have to explicitly pass the dependency

0 commit comments

Comments
 (0)