-
Notifications
You must be signed in to change notification settings - Fork 268
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
New Auto-wiring API #252
Comments
Great work. This is much better than the old auto-wiring. I think its fairly safe to remove the old feature immediately. I'm not sure if its appropriate or possible for us, but DI frameworks in other languages include a qualifier attribute for cases where by type injection is not possible: //Disambiguate and force Typhoon to inject the stub web service
@property(nonatomic, strong) InjectedProtocol(@selector(stubWebService), WebService) webService I can see my self using this for view controllers. Another place where I would particularly like to use it is in Integration tests - so instead of setting up a factory, and pulling components for integrations tests, we could just:
|
I'll update the docs over the weekend. |
Fixes #189 ? |
#189 - yes, it's fixed. |
The old documentation for Autowiring is still over at https://github.com/typhoon-framework/Typhoon/wiki/Autowiring and needs removing. It confused me for a good while! |
@fatuhoku sorry about that. Will update today. |
Today I intoroduced new API for auto-wiring. (I want to remove old one)
It's called auto-injection (to avoid name collision with original auto-wiring)
The auto-injection API looks:
That's all. Typhoon will automatically inject autoQuest property by definition for protocol Quest, and inject autoFort property by definition for class Fort.
Further discussions
Why we need more flexible injection-by-type?
Let's look to the real example: we have webService protocol and two implementation - real and stub.
Assembly can be looks like:
So there is three definitions of same protocol. Injection-by-type will fail with exception for WebService protocol. To handle this situation appropriately, we may need to remove stubWebService and httpWebService from the lookup. Then injection-by type will find only
webService
definition that return right definition based on config value.There is another work to do:
[TyphoonDefinition withOption...
and[TyphoonDefinition withFactory...
definitions should have correct type if possible. Currently they hold [NSObject class] type as stub but this is problem when using "injection-by-type".The text was updated successfully, but these errors were encountered: