From 9ba355b1117c6c2cee310abc5ff69163544011c1 Mon Sep 17 00:00:00 2001 From: Robbie Moyer Date: Thu, 1 Feb 2024 12:21:45 -0500 Subject: [PATCH] Update README with new register APIs --- README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 7e15416..00f91ad 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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() { @@ -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.