Releases: AliSoftware/Dip
Swift 3
New
- Migrated to Swift 3.0
#120, @patrick-lind, @mark-urbanthings, @ilyapuchka - Renamed
DefinitionOf
toDefinition
and some other source-breaking refactoring.
#113, @ilyapuchka - Added
invalidType
error when resolved instance does not implement requested type.
#118, @ilyapuchka - Added optional
type
parameter in register methods to be able to specify type when registering using method literal instead of closure.
#115, @ilyapuchka - Added
implements
family of methods in toDefinition
to register type-forwarding definitions.
#114, @ilyapuchka - Shared scope is now the default scope.
#112, @ilyapuchka - Single target project setup.
#121, @ilyapuchka - Simplified implementation of auto-wiring. Container now chooses the definition for type with most number of arguments and does not use other definitions if this one fails to resolve.
#117, @ilyapuchka
Fixed
- Auto-injected properties inherited from super class are now properly injected when resolving subclass.
AddedresolveDependencies(_:DependencyContainer)
method toResolvable
protocol to handle inheritance when resolving.
#116, @ilyapuchka
4.6.1
New
- Renamed some public API's
#105, @ilyapuchka
Fixed
- Fixed sharing singletons between collaborating containers
#103, @ilyapuchka
Notes on API changes
All changes are made by adding new API and deprecating old versions. They will be removed in the next release.
ObjectGraph
scope is renamed toShared
,Prototype
scope is renamed toUnique
.resolveDependencies
method ofDefinitionOf<T>
is renamed toresolvingProperties
DefinitionKey
propertiesprotocolType
is renamed totype
,associatedTag
is renamed totag
,argumentsType
is renamed totypeOfArguments
.resolve
method parameterwithArguments
is renamed toarguments
. That change affects allresolve
methods ofDependencyContainer
- Order of scope and tag parameters in
register
method is switched. That change affects allregister
methods ofDependencyContainer
Containers collaboration & weak singletons
New features
- Containers collaboration. Break your definitions in modules and link them together.
#95, @ilyapuchka - Added WeakSingleton scope.
#96, @ilyapuchka - Properties auto-injection now is performed before calling
resolveDependencies
block
#97, @ilyapuchka - Fixed updating container's context when resolving properties with auto-injection.
#98, @ilyapuchka - Improved logging.
#94, #99, @ilyapuchka - Fixed warning about using only extensions api.
#92, @mwoollard
Type forwarding, weak types & optionals
New features
- Added weakly-typed API to resolve components when exact type is unknown during compile time.
#79, @ilyapuchka - Added type forwarding feature. You can register the same factory to resolve different types.
#89, @ilyapuchka - Container now can resolve optional types 🎉
#84, @ilyapuchka - Added container context that provides contextual information during graph resolution process.
#83, @ilyapuchka - Added method to validate container configuration.
#87, @ilyapuchka - Added method to manually set value wrapped by auto-injection wrappers.
#81, @ilyapuchka - Added separate error type for failures during auto-wiring.
#85, @ilyapuchka
Note
With introduction of type-forwarding the behavior of func resolveDependencies(block: (DependencyContainer, T) throws -> ()) -> DefinitionOf<T, F>
changed. Now you can call this method several times on the same definition. When instance is resolved using this definition the container will call all the blocks that you passed to this method in the same order as you called this method.
Eager Singletons
New features
- Added
.EagerSingleton
scope for objectes requiring early instantiation andbootstrap()
method onDepenencyContainer
. Callbootstrap
to fix container setup and instantiate all eager singletons.
#65, @ilyapuchka
Bug fixes
- Reverted order of
Resolvable
callbacks. Now last resolvedResolvable
instance will receivedidResolveDependencies
callback first.
#67, @ilyapuchka
Swift 2.2
Fixed
- Fix Swift 2.2 compile errors in tests
#62, @mwoollard
Auto-wiring, Resolvable & DependencyTagConvertible
New features
- Added
DependencyTagConvertible
protocol for better typed tags.
#50, @gavrix - Auto-wiring.
DependencyContainer
resolves constructor arguments automatically.
#55, @ilyapuchka - Added
Resolvable
protocol to get a callback when dependencies graph is complete.
#57, @ilyapuchka - Removed
DipError.ResolutionFailed
error for better consistency.
#58, @ilyapuchka
SMP & Linux
New features
- Added support for Swift Package Manager.
#41, @ilyapuchka - Added Linux support.
#42, #46, @ilyapuchka - Added public
AutoInjectedPropertyBox
protocol for user-defined auto-injected property wrappers.
#49, @ilyapuchka
Bug fixes
- Fixed the issue that could cause singleton instances to be reused between different containers.
#43, @ilyapuchka
Auto-Injection, Errors handling & Thread-Safety
New features
- Added auto-injection feature.
#13, @ilyapuchka - Factories and
resolveDependencies
blocks ofDefinitionOf
are now allowed tothrow
. Improved errors handling.
#32, @ilyapuchka - Thread safety reimplemented with support for recursive methods calls.
#31, @mwoollard
Circular Dependencies & throw
New Features
- Added support for circular dependencies:
- Added
ObjectGraph
scope to reuse resolved instances - Added
resolveDependencies
method onDefinitionOf
class to resolve dependencies of resolved instance.
#11, @ilyapuchka
- Added
- Added methods to register/remove individual definitions.
#11, @ilyapuchka - All
resolve
methods now can throw error if type can not be resolved.
#15, @ilyapuchka DependencyContainer
is marked asfinal
.- Added support for OSX, tvOS and watchOS2.
#26, @ilyapuchka
Breaking Changes
-
Removed container thread-safety to enable recursion calls to
resolve
.
Access to container from multiple threads should be handled by clients from now on. -
All
resolve
methods now can throw.Note on migration from 3.x to 4.0.0:
- Errors
In 4.0.0 each
resolve
method can throwDefinitionNotFound(DefinitionKey)
error, so you need to call it usingtry!
ortry?
, or catch the error if it's appropriate for your case. See #15 for rationale of this change.- Thread safety
In 4.0.0
DependencyContainer
drops any guarantee of thread safety. From now on code that uses Dip must ensure that it's methods are called from a single thread. For example if you have registered type as a singleton and later two threads try to resolve it at the same time you can have two different instances of type instead of one as expected. This change was required to enable recursive calls ofresolve
method to resolve circular dependencies.- Removed methods
Methods deprecated in 3.1.0 are now removed.