Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
hainayanda authored Oct 14, 2024
1 parent 82b8cbd commit 11ac426
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Then, include it in your target:

## Usage

This library is designed to allow easier dependency management, using exisiting EnvironmentValues from SwiftUI. Adding new environment is very easy:
This library is designed to allow easier dependency management, using exisiting `EnvironmentValues` from SwiftUI. Adding new environment is very easy:

```swift
// protocol with stub
Expand All @@ -64,13 +64,20 @@ extension EnvironmentValues {
}
```

Then you can use the keyPath in SwiftUI Environment or GlobalEnvironment:
Then you can use the keyPath in SwiftUI `Environment` or `GlobalEnvironment`:

```swift
@Environment(\.myValue) var switUIValue
@GlobalEnvironment(\.myValue) var globalValue
```

You can inject the dependency to SwiftUI Enviromnent as usual:

```swift
SomeView()
.environment(\.myValue, SomeDependency())
```

Different than SwiftUI Environment, GlobalEnvironment can be injected and accessed globally:

```swift
Expand Down

0 comments on commit 11ac426

Please sign in to comment.