-
Notifications
You must be signed in to change notification settings - Fork 535
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add an async call in the component initialization path #1905
Comments
I feel like there are only two flows:
I think you are saying there 3rd option here, but I'm not sure what is it (from POV of entity who loads that component)? |
Yes, there should be these two flows. Right now componentHasInitialized is part of #1 above and we don't have a #2 right? |
I think #2 is just calling async function and not awaiting it, no? |
I believe so. Maybe we can add a function called postInitialization or something and in SharedComponent.initialize(), call it without awaiting or in this.initializeInternal().then(postInitialization)? |
All methods are async: I believe adding more more method that is async but factory does not wait for would be very confusing, as (on initial look) it would not be clear how it differs from hasInitialized. That, and the fact that there was no movement, means punt. |
We may need an async step in the component initialization path that will be called after initialize, i.e. after componentInitializingFirstTime/componentInitializingFromExisting and componentHasInitialized are done.
The above methods are called synchronously and there is no way for components to do additional setup work after the component has finished initializing. I mean they can probably schedule async tasks from componentHasInitialized but it might be worth to explicitly provide a way to do that.
Some context as to why I am suggesting this
I ran into this circular dependency problem when using root component in Vltava to integrate LastEditedTracker. Basically, the problem is that any component that need access to functionality provided by the root component have to do so after the root component has completed initializing (so that they can request it).
This means they cannot do that in the componentHasInitialized method unless they fire off an async task or do it in response to some other event (like in #1784, I do it in response to a user action).
I believe it might be worth to provide a function "post" initialization so they can do things like
requesting IComponent* from the root component.
I feel this may make the root component model a bit simpler to use.
Please let me know your thoughts @anthony-murphy @skylerjokiel @vladsud @curtisman
The text was updated successfully, but these errors were encountered: