When registering an optional property, it can not be resolved by the property wrapper even when it's available (not nil).
Example:
class Foo {
@Inject var bar: Int?
}
container.register(Int?.self) { _ in
return 42
}.inObjectScope(.container)
From the docs I assume this should be supported and I have also seen an init created for Optionals, however that init is not used. I am not sure I fully understand the rationale behind how this generic init (on line 28) is supposed to work, but I believe for optional properties to resolve properly, the wrappedValue should be of an optional type as well or the Wrapped type should be passed as an argument to the generic init method, otherwise it is not used anywhere in the method body.
Looking forward to your reply, thanks.
When registering an optional property, it can not be resolved by the property wrapper even when it's available (not nil).
Example:
From the docs I assume this should be supported and I have also seen an
initcreated forOptionals, however thatinitis not used. I am not sure I fully understand the rationale behind how this generic init (on line 28) is supposed to work, but I believe for optional properties to resolve properly, thewrappedValueshould be of an optional type as well or the Wrapped type should be passed as an argument to the genericinitmethod, otherwise it is not used anywhere in the method body.Looking forward to your reply, thanks.