Resolve operators
jakubvano opened this issue · comments
We want to add resolve operators for more concise and readable syntax - typically they would be used where autoregistration cannot be, e.g. when you need to define explicit types / names.
Various versions are discussed here, most fitting operator seems to be ~>
with usage:
MyService(dependencyA: r~>)
MyService(dependencyA: r ~> (DependencyA.self, name: "name"))
MyService(dependencyA: r ~> (DependencyA.self, arguments: (arg1, arg2)))
Alternative for simple resolve would be <~
with usage
MyService(dependencyA: <~r)
Prefix form is however not usable for more complex cases, and having multiple operators is inconsistent and confusing.
As discussed, ~>
looks consistent for me too.
The operator was added in https://github.com/Swinject/SwinjectAutoregistration/blob/master/SwinjectAutoregistration/Classes/Operators.swift
Also notice that the infix operator is not declared because is already declared in swift (though I have no idea what it is for :)). Looks like this:
infix operator ~> {
associativity left
precedence 255
}
but as far as I know, no functions are using it.
If everything is ok, we can close this issue.
Also - the file is now not autogenerated. It would be nice to use some .erb in future.