Releases: AliSoftware/Dip
Swift 3
New
- Migrated to Swift 3.0
#120, @patrick-lind, @mark-urbanthings, @ilyapuchka - Renamed
DefinitionOftoDefinitionand some other source-breaking refactoring.
#113, @ilyapuchka - Added
invalidTypeerror when resolved instance does not implement requested type.
#118, @ilyapuchka - Added optional
typeparameter in register methods to be able to specify type when registering using method literal instead of closure.
#115, @ilyapuchka - Added
implementsfamily of methods in toDefinitionto 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 toResolvableprotocol 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.
ObjectGraphscope is renamed toShared,Prototypescope is renamed toUnique.resolveDependenciesmethod ofDefinitionOf<T>is renamed toresolvingPropertiesDefinitionKeypropertiesprotocolTypeis renamed totype,associatedTagis renamed totag,argumentsTypeis renamed totypeOfArguments.resolvemethod parameterwithArgumentsis renamed toarguments. That change affects allresolvemethods ofDependencyContainer- Order of scope and tag parameters in
registermethod is switched. That change affects allregistermethods 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
resolveDependenciesblock
#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
.EagerSingletonscope for objectes requiring early instantiation andbootstrap()method onDepenencyContainer. Callbootstrapto fix container setup and instantiate all eager singletons.
#65, @ilyapuchka
Bug fixes
- Reverted order of
Resolvablecallbacks. Now last resolvedResolvableinstance will receivedidResolveDependenciescallback first.
#67, @ilyapuchka
Swift 2.2
Fixed
- Fix Swift 2.2 compile errors in tests
#62, @mwoollard
Auto-wiring, Resolvable & DependencyTagConvertible
New features
- Added
DependencyTagConvertibleprotocol for better typed tags.
#50, @gavrix - Auto-wiring.
DependencyContainerresolves constructor arguments automatically.
#55, @ilyapuchka - Added
Resolvableprotocol to get a callback when dependencies graph is complete.
#57, @ilyapuchka - Removed
DipError.ResolutionFailederror 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
AutoInjectedPropertyBoxprotocol 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
resolveDependenciesblocks ofDefinitionOfare 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
ObjectGraphscope to reuse resolved instances - Added
resolveDependenciesmethod onDefinitionOfclass to resolve dependencies of resolved instance.
#11, @ilyapuchka
- Added
- Added methods to register/remove individual definitions.
#11, @ilyapuchka - All
resolvemethods now can throw error if type can not be resolved.
#15, @ilyapuchka DependencyContaineris 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
resolvemethods now can throw.Note on migration from 3.x to 4.0.0:
- Errors
In 4.0.0 each
resolvemethod 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
DependencyContainerdrops 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 ofresolvemethod to resolve circular dependencies.- Removed methods
Methods deprecated in 3.1.0 are now removed.