Skip to content
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

Closed
agarwal-navin opened this issue Apr 23, 2020 · 5 comments
Closed

Add an async call in the component initialization path #1905

agarwal-navin opened this issue Apr 23, 2020 · 5 comments
Assignees
Labels
area: framework Framework is a tag for issues involving the developer framework. Eg Aqueduct design-required This issue requires design thought

Comments

@agarwal-navin
Copy link
Contributor

agarwal-navin commented Apr 23, 2020

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

@agarwal-navin agarwal-navin added area: framework Framework is a tag for issues involving the developer framework. Eg Aqueduct design-required This issue requires design thought labels Apr 23, 2020
@agarwal-navin agarwal-navin self-assigned this Apr 23, 2020
@ghost ghost added the triage label Apr 23, 2020
@vladsud
Copy link
Contributor

vladsud commented Apr 23, 2020

I feel like there are only two flows:

  1. Something is done as part of component loading, i.e. it has to complete as part of componentInitializingFirstTime / componentInitializingFromExisting flow and blocks it
  2. Something is done async to that workflow (i.e. component loading does not wait for it).

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)?

@agarwal-navin
Copy link
Contributor Author

I feel like there are only two flows:

  1. Something is done as part of component loading, i.e. it has to complete as part of componentInitializingFirstTime / componentInitializingFromExisting flow and blocks it
  2. Something is done async to that workflow (i.e. component loading does not wait for it).

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?

@vladsud
Copy link
Contributor

vladsud commented Apr 23, 2020

I think #2 is just calling async function and not awaiting it, no?

@agarwal-navin
Copy link
Contributor Author

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)?

@vladsud
Copy link
Contributor

vladsud commented May 28, 2021

All methods are async:
protected async initializingFirstTime(props?: S): Promise { }
protected async initializingFromExisting(): Promise { }
protected async hasInitialized(): Promise { }

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.
Given that what you ask can be accomplished today (by simply launching async task from hasInitialized), I do not see a need to add it to framework - this (if needed), can be done as in derived class.

That, and the fact that there was no movement, means punt.
Please reactivate if disagree.

@vladsud vladsud closed this as completed May 28, 2021
@danielroney danielroney removed this from the Future milestone Jun 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: framework Framework is a tag for issues involving the developer framework. Eg Aqueduct design-required This issue requires design thought
Projects
None yet
Development

No branches or pull requests

4 participants