AliSoftware / Dip

Simple Swift Dependency container. Use protocols to resolve your dependencies and avoid singletons / sharedInstances!
MIT License
978 stars 75 forks source link

Receiving Build Error #208

Closed adirburke closed 5 years ago

adirburke commented 5 years ago

Line of code

container.register { EmailService(emailConfiguration: $0, issueService: $1, configuration: $2, imageService: $3, roomService: $4, emailRepository: $5, gmailService: $6) as EmailServiceProtocol }

Cannot invoke 'register' with an argument list of type '((EmailConfiguration, IssueServiceProtocol, Configuration, IssueImagesServiceProtocol, RoomServiceProtocol, EmailRespositoryProtocol, GoogleServiceProtocol) -> EmailServiceProtocol)'

  1. Overloads for 'register' exist with these partially matching parameter lists: (ComponentScope, type: T.Type, tag: DependencyTagConvertible?, factory: @escaping (()) throws -> T), (ComponentScope, type: T.Type, tag: DependencyTagConvertible?, factory: @escaping ((A)) throws -> T), (ComponentScope, type: T.Type, tag: DependencyTagConvertible?, factory: @escaping ((A, B)) throws -> T), (ComponentScope, type: T.Type, tag: DependencyTagConvertible?, factory: @escaping ((A, B, C)) throws -> T), (ComponentScope, type: T.Type, tag: DependencyTagConvertible?, factory: @escaping ((A, B, C, D)) throws -> T), (ComponentScope, type: T.Type, tag: DependencyTagConvertible?, factory: @escaping ((A, B, C, D, E)) throws -> T), (ComponentScope, type: T.Type, tag: DependencyTagConvertible?, factory: @escaping ((A, B, C, D, E, F)) throws -> T)
adirburke commented 5 years ago

It looks like I can not register with 6 injections, How can I work around this?

xrayman commented 5 years ago

According to this - https://github.com/AliSoftware/Dip/wiki/runtime-arguments you can only use 6 runtime arguments $0...$5. So in order to use more than that you can create your own overload. Or you can call resolve() on a container instead of $x argument.

ilyapuchka commented 5 years ago

@idi888 please follow a comment in the documentation for register methods, it has instructions for how to extend number of arguments.