-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
This feature implements "deferred" injection by allowing the @Inject() decorator to be used on fields and properties with set accessors. This will effectively allow "seamless" circular dependencies when they are needed, since properties and fields not defined in the constructor can be injected after the host class is instantiated.
Acceptance Criteria
-
@Inject()decorator is updated to be both a param and property decorator (note: hybrid decorators can be defined by using an intersection type of the decorator types -ParamDecorator & PropertyDecorator - injector/generator injects fields/properties after the "initial" hierarchy is instantiated. Constructor dependencies are recursed, so injectable classes will basically need to have a second recursion tree for the properties after the instance is created
-
@Inject()throws an error when used on a property with nosetaccessor - since fields will need to be set outside the constructor, this will likely not work on
readonlyfields - in this case,@Inject()should throw for those too
To Discuss
- Is this a bad idea? E.g. will it enable/encourage bad practices?
- Are there cases when fields/properties will not be able to be set before exposing the instance to the consumer? If so, does the consumer need to be notified of when the values are available?
Reactions are currently unavailable