-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
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
Auto-inject parameter of primitive data type into Singleton #2
Labels
enhancement
New feature or request
Comments
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 🙌🏻 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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: