tsyringe
tsyringe copied to clipboard
Inject into named destructured bag?
Is there any way to easily inject into a constructor that does something like this
export class Foo {
constructor({
foo,
bar,
baz
}: { foo: Foo, bar: Bar, baz: Baz}) {}
}
This is a pretty common pattern in existing codebases to be able to leverage named properties and then desugar them in the constructor to bind to local fields. But it seems wreak havoc on migrating to a DI container since you now need to wrap all these custom classes in factory providers in the container kernel.
Really just asking if anyone has experience on good patterns to leverage here. Thanks!