0

I'm new to Inversify but want to utilise it in the codebase I'm working in. In this codebase, the dependencies are injected via an args object as a means to simulate named constructor parameters. What would be the best way to decorate this object for injection with Inversify, since I'm not able to simply do something like constructor(@inject("FooService") fooService, @inject("BarService") barService)?

interface FooService {
  ...
}

interface BarService {
  ...
}

type FooBarArgs = {
  fooService: FooService;
  barService: BarService;
}

@injectable()
class FooBar 
{
  private fooService: FooService;
  private barService: BarService;
  
  constructor(args:FooBarArgs) {
     this.fooService = args.fooService;
     this.barService = args.barService;
  }
}
pantryfight
  • 338
  • 1
  • 3
  • 13

0 Answers0