We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Currently it's not possible to directly inject parameters such as String, Int etc. using the AutoSetup protocol.
String
Int
AutoSetup
The following code will result in a crash:
/// @Singleton class ApiClient { private let baseUrl: String init(baseUrl: String) { self.baseUrl = baseUrl } }
Error: DependencyContainer.ResolveError<Swift.String>.notRegistered
DependencyContainer.ResolveError<Swift.String>.notRegistered
DependencyContainer does already support injecting and resolving objects using a Key: AnyHashable.
DependencyContainer
Key: AnyHashable
The question is how to integrate that feature using the AutoSetup code generation?
The text was updated successfully, but these errors were encountered:
For now, there is a simple workaround available:
1. Create a wrapper type for your parameter(s)
Using the example above:
/// @Singleton class ApiClient { struct Config { let baseUrl: String } init(config: Config) { self.baseUrl = config.baseUrl } }
2. Manually register the wrapper type
Using the override function of your dependencies entry point:
struct YourDependencies: AutoSetup { func override(_ container: DependencyContainer) throws { container.register { ApiClient.Config(baseUrl: "{YOUR_API_URL}") } } }
Hope that unblocks everyone for now! Will update this issue once support for this feature is available 🙌🏻
Sorry, something went wrong.
No branches or pull requests
Feature Request
Currently it's not possible to directly inject parameters such as
String
,Int
etc. using theAutoSetup
protocol.The following code will result in a crash:
Error:
DependencyContainer.ResolveError<Swift.String>.notRegistered
Proposed Solution
DependencyContainer
does already support injecting and resolving objects using aKey: AnyHashable
.The question is how to integrate that feature using the
AutoSetup
code generation?The text was updated successfully, but these errors were encountered: