You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jul 3, 2019. It is now read-only.
Instead of letting SwiftSuspenders directly handle the creation of injected values, it might sometimes be useful to delegate that to a factory. sammyt's Dawn framework supports factory injections, which looks like a perfect match for this functionality.
The second option will enabled configuring a specific instance of the factory. It might be more useful to use child injectors for configuring the factory itself.
The text was updated successfully, but these errors were encountered:
Should the first snippet read Injector#mapFactoryClass()? What is a factory? Did you like his Provider annotation? That could negate any inter-library interface dependency.
Yes, that's what I meant, thanks. I've corrected the text.
I like the [Provider] annotation indeed: Much better than to prescribe an interface for the factory. Also, it enables multiple factory methods in one class, each annoted with [Provider] and selected by its return type.
I haven't found any standard annotations, but will look some more. If Guice or Spring support something similar, it might be worthwhile to use they annoation syntax.
Instead of explicitly supporting factory mappings, Swiftsuspenders 2 will have a generic way of mapping to custom providers that only need to implement the method apply(targetClass:Class, usingInjector:Injector):Object. To make it easier to use the custom provider, Swiftsuspenders 2 comes bundled with a FactoryProvider that takes a Class implementing DependencyProvider as a ctor argument and construct an instance of that class for each application, enabling easy implementation of DepencyProviders with their own dependencies.
Instead of letting SwiftSuspenders directly handle the creation of injected values, it might sometimes be useful to delegate that to a factory.
sammyt's Dawn framework supports factory injections, which looks like a perfect match for this functionality.
Syntax proposal:
and
The second option will enabled configuring a specific instance of the factory. It might be more useful to use child injectors for configuring the factory itself.
The text was updated successfully, but these errors were encountered: