All Versions
7
Latest Version
Avg Release Cycle
51 days
Latest Release
1570 days ago
Changelog History
Changelog History
-
v0.2.2 Changes
December 04, 2020๐ Changes
- โก๏ธ Updates
crystal
version to be installable in Crystal versions greater than1.0.0
- โก๏ธ Updates
-
v0.2.1 Changes
November 14, 2020โฌ๏ธ Dependency Upgrades
โ Additions
- โ Adds a standardized way to handle "mocking" services for testing
- ๐ Support being able to specify the type of a service within a container
- Used to support interface based mocking. See this section in the API docs
- ๐ Supports creating services via the Factory pattern
๐ Changes
- ๐ Update
deploy_docs
CI job to use updated version of pages deploy and usesGITHUB_TOKEN
.
-
v0.2.0 Changes
June 09, 2020๐ This release includes an overhaul of the DI implementation; in turn bringing about many improvements to the shard. See the linked sections in the API documentation for more details/examples.
Highlights
- The
ADI::Service
module is no longer required to register a service - Service dependencies are now automatically resolved (for the most part)
- ๐จ Internal refactors to make the code easier to maintain, more extendable, and fixes a bunch of edge cases
โฌ๏ธ Dependency Upgrades
โ Additions
- Introduces concept of
lazy
services- Lazy services are not instantiated in the container until manually retrieved (if
public
), or used as a dependency of another service - Defaulted to
true
, but can be overwritten by settinglazy: false
within theADI::Register
annotation - In the future, this could possibly be expanded to only instantiate them when they are first used (i.e. some method being called)
- Lazy services are not instantiated in the container until manually retrieved (if
- Introduce concept of Aliasing Services
- Allows defining a "default" service that will be injected when an argument restricted to that default service's interface is encountered
- Introduce concept of Bindings
- Bindings allow scalar values, or those that could not otherwise be handled via aliases, to be auto registered
- Bindings can also be declared with a type restriction to allow taking the type restriction of the argument into account
- ๐ง Introduce concept of Auto Configuration
- Allows applying service configuration, such as
public
,tags
, orlazy
options to any service of a specific type - A common use case would be wanting to apply a specific tag to all instances of an interface, versus having to manually apply the tag to each implementation
- Allows applying service configuration, such as
- Introduce the ADI::Inject annotation
- Allows specifying which constructor will be used for injection
- ๐ Allow Generic Services
- Allows services to be registered based on a generic type
- Generic arguments are provided as positional arguments within the
ADI::Register
annotation
๐ Changes
- ๐จ Refactor Tagged Services
- Uses a more robust implementation, fixes some edge cases
- Initial implementation for tag metadata, currently only supports
priority
which controls the order in which the services are injected; the higher the priority the sooner in the array it would be
- ๐จ Refactor Optional Services to be based on type restrictions/default values
- (breaking-change) The syntax for manually providing service dependencies has changed to using the argument's name prefixed with a
_
symbol as named arguments within theADI::Register
annotation- If the argument was
@debug : Bool
you would add_debug: true
into the annotation - The syntax is similar as it was before for services,
@my_service : MyService
would be_my_service: "@my_service"
- If the argument was
- (breaking-change) Service names are now based on the
FQN
of the type downcase underscored by defaultMyApp::SomeModule::Service
would becomemy_app_some_module_service
- Can still be overwritten via the
name
field within theADI::Register
annotation
Removals
- (breaking-change) The
ADI::Service
module has been removed- Only the
ADI::Register
annotation is required now to register a service with the container
- Only the
- (breaking-change) Service dependencies are now resolved automatically
- Arguments no longer have to be supplied as positional arguments
- See the Basic Usage example for more details
- Compile time errors are raised if a service could not be auto registered due to a missing service, ambiguity, or a scalar value without a binding
- (breaking-change) Removes the
@?
syntax as it is no longer needed - (breaking-change) Removes some methods on the container including:
#get
,#has?
,#resolve
,#tagged
, and#tags
#has?
has been replaced withcontainer.responds_to? :my_service
#get
/#resolve
and#tagged
/#tags
are now obsolete
- (breaking-change) Removes the
ADI::Injectable
module- This was kind of an anti-pattern for allowing non services to use services
- A more proper solution is to make everything a service to make use of the automatic dependency resolution
- Alternatively, services could be make
public
and retrieved directly from the container within the non service; although this still slightly a code smell
- The
-
v0.1.3 Changes
April 06, 2020๐ Bug Fixes
- Check includers via <= #7
-
v0.1.2 Changes
February 22, 2020๐ Changes
- Resolve types at compile time versus runtime #6
-
v0.1.1 Changes
February 07, 2020๐ New Features
- ๐ Allow redefining services
- See the docs.
- ๐ Allow redefining services
-
v0.1.0
January 31, 2020