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.