I want to create a factory that is able to create a new instance of a class (MyClass, implementing an abstract class) that is using dependency injection.
I would like the factory to look like this:
Factory
export class Factory {
public static makeMyClass() {
return new MyClass();
}
}
However, the EventAggregator is not injected into MyClass when I take this approach.
How can I do this?
Interface
export abstract class MyClassInterface {
abstract connect();
abstract disconnect();
abstract send(message: string);
}
Class
@inject(EventAggregator)
export class MyClass {
constructor(EventAggregator) {}
connect() {}
disconnect() {}
send(message: string) {}
}
Thanks in advance!