Skip to content

Commit

Permalink
Update README.md (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
0xLeif authored Nov 5, 2023
1 parent a290b0a commit 2eeab55
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,8 @@ Here's an example:
```swift
class DataService: ObservableObject {
@AppState(\.someData) var data: [String]

func fetchData() { ... }
}

extension Application {
Expand Down Expand Up @@ -196,7 +198,7 @@ In this example, whenever data in `DataService` changes, SwiftUI automatically u

One of the great advantages of using `Dependency` in AppState is the capability to replace dependencies with mock versions during testing. This is incredibly useful for isolating parts of your application for unit testing.

You can replace a dependency by calling the `override(_:_:)` function. This function returns a `DependencyOverrideToken`, you'll want to hold onto this token for as long as you want the mock dependency to be effective. When the token is deallocated, the dependency reverts back to its original condition.
You can replace a dependency by calling the `Application.override` function. This function returns a `DependencyOverride`, you'll want to hold onto this token for as long as you want the mock dependency to be effective. When the token is deallocated, the dependency reverts back to its original condition.

Here's an example:

Expand Down

0 comments on commit 2eeab55

Please sign in to comment.