feat: implement async component initializers #209
Conversation
Since components may require async initializers (e.g. to connect to some resource) the dependency tree could only be created async in some cases. To support this tsdi calls component initializers only if all injected component initializers are done. Closes #208
I'd suggest to add a method to tsdi which can be awaited and which will resolve once all async initializers are done. This way it's for example possible to hold the initial rendering of a page until all api requests are performed. Also, sometimes it might not be desirable to always await all initializers just because they return a promise. We could add a I can try to tackle that and also take a look at What do you mean by |
I would like to add a method (e.g. If an initializer returns a promise this will not be enough (right now it is, but I have to rework a smaller part). It is requried to declare the initializer as async which will implicitly let dependencies wait for it. Would be awesome if you create a test with deeper async level. The main focus should be that there is a dependency which async initializer which is injected into a component without async initializer. That one in turn is also injected and must be awaited because of the deeper async initializer.
|
Okay then I'll take a look at the test. |
Since components may require async initializers
(e.g. to connect to some resource) the dependency
tree could only be created async in some cases.
To support this tsdi calls component initializers
only if all injected component initializers are done.
There are a few parts missing in this implementation.
async
)Closes #208