square / Cleanse

Lightweight Swift Dependency Injection Framework
Other
1.79k stars 90 forks source link

Question: injection with arguments #34

Closed charlag closed 7 years ago

charlag commented 7 years ago

Thanks for the awesome library! README says that assisted injection is not supported. I was wondering, what is the recommended solution for it until it is supported? Should I create factories and write bindings for them or there is a better pattern? Interface + implementation + factory + module sounds like a lot of code. Thanks!

mikelikespie commented 7 years ago

HI @charlag! We support something like this on our working branch with Components & ComponentFactories

https://github.com/square/Cleanse/pull/27

See https://github.com/square/Cleanse/blob/f4d3b8db9a02e14bcfb0e153572c3f8594721212/CleanseTests/ComponentTests.swift#L31 for example

This branch is more or less finished minus some tests and updating docs. I think it should fill your use case :)

charlag commented 7 years ago

Thanks! SGTM. I will migrate from Swinject in the next few months, let's see how this will work. It's not Swift 3 only yet, right?

mikelikespie commented 7 years ago

@charlag Nope! Not swift 3 only yet. Branch in #27 has all improvements that we're planning on for swift 3 release. We'd love to hear experience switching from Swinject to Cleanse if you want to report back.