Open shtse8 opened 2 years ago
Finally I can achieve this. Here is my implementation. Just wondering if it is proper way to do.
for (const config of configs)
container.bind<Config>(TYPES.Config).toConstantValue(config).whenParentTagged('config', config)
container.bind<Runner>(TYPES.Runner).to(Runner)
container.bind<interfaces.Factory<Runner>>(TYPES.RunnerFactory).toFactory<Runner, [Config]>(context => config => context.container.getTagged<Runner>(TYPES.Runner, 'config', config))
const configs = container.getAll<Config>(TYPES.Config)
const runnerFactory = container.get<interfaces.Factory<Runner>>(TYPES.RunnerFactory)
const runners = configs.map(runnerFactory)
Consider this setup:
I can get all configs by
Also, I can get one parent by
But, how to get all runners for each config?
Or, is it possible to get all named on Config, so that I can get all by one by one?