Skip to content

Commit

Permalink
update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryu0118 committed Sep 30, 2023
1 parent 0a647b9 commit 2fc88c2
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ import DependenciesMacro
public struct TestClient {
public var request: @Sendable (_ request: Request) -> Void
}

@DependencyValue(TestClient.self)
public extension DependencyValues {}
```
`@PublicInit` is a Member Macro and provides a public initializer.
This macro can be applied only to public structs.
Expand All @@ -31,17 +34,18 @@ extension TestClient: TestDependencyKey {
request: unimplemented("\(Self.self).request")
)
}

public extension DependencyValues {
var testClient: TestClient {
get {
self[TestClient.self]
}
set {
self[TestClient.self] = newValue
}
}
}
```
> [!WARNING]
> The following DependencyValues extension are not generated by macro
> ```Swift
> public extension DependencyValues {
> var testClient: TestClient {
> get { self[TestClient.self] }
> set { self[TestClient.self] = newValue }
> }
> }
> ```

## Installation
This library can only be installed from swift package manager.
Expand Down

0 comments on commit 2fc88c2

Please sign in to comment.