Skip to content

Commit

Permalink
Update README with new register APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
moyerr committed Feb 1, 2024
1 parent 581ac3d commit 9ba355b
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ Grove simplifies dependency registration and resolving. Here's an example:
let container = Grove.defaultContainer // You can use the default container or create your own

// Register a reference type dependency as a singleton
container.register(JSONEncoder.init)
container.register(JSONEncoder())

// or with a transient lifetime
container.register(scope: .transient, JSONEncoder.init)
container.register(scope: .transient, JSONEncoder())

// Register a value type dependency (an enum for example)
container.register(value: DeploymentEnvironment.production)
container.register(DeploymentEnvironment.production)
```

### Resolution
Expand Down Expand Up @@ -75,7 +75,7 @@ final class DependenciesRegistrar {
return decoder
}

container.register(as: NASARepositoryProtocol.self, NASARepository.init)
container.register(as: NASARepositoryProtocol.self, NASARepository())
}

static func registerMocks() {
Expand All @@ -91,12 +91,12 @@ final class DependenciesRegistrar {
return decoder
}

container.register(as: NASARepositoryProtocol.self, MockNASARepository.init)
container.register(as: NASARepositoryProtocol.self, MockNASARepository())
}
}
```

You can then call DependenciesRegistrar.register() from your App's init() or AppDelegate. For unit tests or SwiftUI previews, you can call DependenciesRegistrar.registerMocks().
You can then call `DependenciesRegistrar.register()` from your App's `init()` or `AppDelegate`. For unit tests or SwiftUI previews, you can call `DependenciesRegistrar.registerMocks()`.

## Contributing
Contributions are immensely appreciated. Feel free to submit pull requests or to create issues to discuss any potential bugs or improvements.
Expand Down

0 comments on commit 9ba355b

Please sign in to comment.