Hi all,
I’m having a hard time finding an example of a factory resolver using parameter decorators (in TypeScript). I can’t figure out how to declare the resolver, nor how to use it! Something like constructor(@factory(SomeClass) someClassFactory: /* type? */) { ... }
This is what I have so far:
// the factory
@inject(BindingEngine, EventAggregator)
export class SomeClass {
constructor(
private readonly bindingEngine: BindingEngine,
private readonly eventAggregator: EventAggregator,
private readonly foo: /* some custom dependency */) { }
publicMethod() { ... }
}
// the consumer
@autoinject() // not sure if I can do this?
export class SomeCustomElement {
constructor(@factory(SomeClass) private readonly someClassFactory: /* what type? */) { }
bind() {
var foo = { /* localised dependencies */ };
var someClassInstance: SomeClass = this.someClassFactory(foo);
// then I want to:
someClassInstance.publicMethod();
}
}
I can use @inject(Factory.of(SomeClass))
but I’d like to try the parameter decorator as well.
thanks!