-
-
Notifications
You must be signed in to change notification settings - Fork 20
Description
The DI component currently has some features that are implemented at top level macro calls. Specifically .bind and .auto_configure. These were implemented like that for reasons, mainly not having thought of a better way, and due the increased complexity of the alternatives.
However with the introduction of #337, the DI component is a lot more robust and flexible when it comes to adding in features. As such, I propose we start to deprecate the "legacy" macros calls where possible into annotations that can be applied closer to the source.
E.g. something like:
module ConfigInterface; end
ADI.auto_configure ConfigInterface, {tags: ["config"]}Could become:
@[ADI::Autoconfigure(tags: ["config"])]
module ConfigInterface; endThere is also room to improve how other DI features work by adding additional annotations. Service aliasing for example. Instead of:
module TransformerInterface; end
@[ADI::Register(alias: TransformerInterface)]
struct ShoutTransformer
include TransformerInterface
endYou could do
module TransformerInterface; end
@[ADI::Register]
@[ADI::AsAlias(TransformerInterface)]
struct ShoutTransformer
include TransformerInterface
endThis is nice not only from a readability perspective, but also from an implementation POV as it decouples the alias logic from the Register annotation itself.