Is it possible for TSyringe to inject all classes that implement a specific interface or extend an abstract class? For example:
@injectable()
export interface IService {
foo(): void;
}
@injectable()
export class Service1 implements IService {
foo() { console.out("bar"); }
}
@injectable()
export class Service2 implements IService {
foo() { console.out("baz"); }
}
export class CollectorService {
constructor(
@inject('Service')
services: IService[]
) {
services.forEach(s => s.foo());
}
}
I recently started using TSyringe and I'm not sure how to register this kind of dependency in the DI container. I'd like to achieve something similar to Spring's @Autowire
annotation.