I'm trying to design a system that inject configuration of each component into each class.
project structure:
|features
--|component-a
component-a.service.js
component-a.config.json
--|component-b
component-b.service.js
component-b.config.json
--|component-c
component-c.service.js
component-c.config.json
I think about 2 approaches to inject the config:
Create a class config which receives the name of the component and locate it, then initialize the attributes from the
component-x.config.json
file, and eachcomponent-x
class inherits from the class config.Use an injector that locate the configuration file for the dependent class when it will be needed for the client.
Load the config file for each component and initialize the attributes inside the component constructor explicitly.
Which approach will be better to use with dependency injection pattern?