You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In one of my applications, I have quite a few services which require explicit bootstrapping
before they can be safely used. In the case of that specific application, my solution boiled
down to a bootstrap (): Promise<void> method on services that needed to perform an
asynchronous action before it was usable.
There might be a way to solve this in DI.
While it looks like there was a proposal to add asynchronous services in TypeDI, it never emerged.
Additionally, it introduced a substantial amount of complexity into the API.
Another problem with that proposal was forcing all asynchronous services to be "ready"
before any other services could run. This, of course, has the side effect of slowing down the app.
Any important synchronous tasks can't be performed until everything is ready.
This would, of course, quickly bog the application down when a number of async services are introduced.
As a result, I'd like to create a different API that would handle this differently.
Namely, some of the design proposals for this API include:
Being able to import asynchronous services without "initialising" them.
Not having to wait for every asynchronous service to load before the app can start.
Being able to control the order of execution for asynchronous services.
Definitely food for thought.
The text was updated successfully, but these errors were encountered:
After careful consideration, the execution and orchestration of asynchronous services does not fall under the scope of TypeDI. These could be implemented by way of service buffering, which I am working on in a separate package.
In one of my applications, I have quite a few services which require explicit bootstrapping
before they can be safely used. In the case of that specific application, my solution boiled
down to a
bootstrap (): Promise<void>
method on services that needed to perform anasynchronous action before it was usable.
As a result, a lot of services ended up like:
There might be a way to solve this in DI.
While it looks like there was a proposal to add asynchronous services in TypeDI, it never emerged.
Additionally, it introduced a substantial amount of complexity into the API.
Another problem with that proposal was forcing all asynchronous services to be "ready"
before any other services could run. This, of course, has the side effect of slowing down the app.
Any important synchronous tasks can't be performed until everything is ready.
This would, of course, quickly bog the application down when a number of async services are introduced.
As a result, I'd like to create a different API that would handle this differently.
Namely, some of the design proposals for this API include:
Definitely food for thought.
The text was updated successfully, but these errors were encountered: