Open Murzbul opened 1 month ago
InjectorContext
is not available in the low level API. It is only available in the App
abstraction of @deepkit/app
.
As a side note: if your MyService needs Database, you should just reference Database in the constructor instead of using the InjectorContext. InjectorContext is only necesary to either delay intantiation or load services dynamically. You should try to stay away from it to not tightly couple your code too much to the DI container or use the DI container as metasystem
Thank you very much for the message.
In reality, it is a mere example.
What I would like to build is a SimpleCQRS.
So I need some way to get the context to add the handlers.
The idea is to create a simple module.
For example
export const CqrsModule = new InjectorModule([
{provide: CommandBus, useClass: SimpleCommandBus},
{ provide: QueryBus, useClass: SimpleQueryBus }
]).forRoot();
As a first module.
Then add another module and get the SimpleCommandBus to add the corresponding handlers.
Hi!
I have some tests with the InjectorContext and InjectorModule.
I've tested the docs example to inject the InjectorContext but it doesn't work.
This is the error.
I don't know if there is a bug or if I have a mistake understanding here with the docs.