You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 no set accessor
since fields will need to be set outside the constructor, this will likely not work on readonly fields - 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?
The text was updated successfully, but these errors were encountered:
This feature implements "deferred" injection by allowing the
@Inject()
decorator to be used on fields and properties withset
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
@Inject()
throws an error when used on a property with noset
accessorreadonly
fields - in this case,@Inject()
should throw for those tooTo Discuss
The text was updated successfully, but these errors were encountered: