My colleague uses a lot of complex approaches developing his lwc components, so when I want to learn something new, I just look at his code ) But always good to have a good explanation, thanks!
Great video and explanation. I am working through a scenario which I have a parent Aura component and child LWC. I need response data from a callout to use with the child LWC. I am trying to determine if it is best to make the callout in the parent AURA and rely on the response data to be captured in a variable and passed to the child LWC. This I believe would require initializing the child LWC after response is return from callout OR execute the callout from the child as an await function in the async connectedCallback. Thoughts?
Thanks for the feedback. Without seeing the source code, I will make some assumptions here but perhaps you could do the callout in the parent and pass the data down to the child. This provides better decoupling (the LWC only focuses on rendering) and this eases testing. You would have to ensure that your LWC doesn't crash when passed the initially "empty" data while waiting for the callout. I generally have a "loading" state that displays a spinner while waiting for async data. You can do this in the parent or the child.
@@pozil Thanks for following up. That is interesting you mention the Parent cmp. That was my initial thought; however, my concern was this "loading" state EXACTLY. Do you have a resource or code snippet I could reference that shows this loading state gating? That would be awesome.
@@pozil So I took a look at this. I see the spinner for sure. Would the 'inLoading' variable be used in a template directive around the child component to only load the child component when ? This is the way I am understanding concept.
The greates class regarding async js patterns. Thanks a lot!
You're very welcome!
This is one of the best videos I have seen on the subject. Thank you!
Nicely explained, I liked the way this complex topic is covered
My colleague uses a lot of complex approaches developing his lwc components, so when I want to learn something new, I just look at his code ) But always good to have a good explanation, thanks!
Great explanation.
Great video and explanation. I am working through a scenario which I have a parent Aura component and child LWC. I need response data from a callout to use with the child LWC. I am trying to determine if it is best to make the callout in the parent AURA and rely on the response data to be captured in a variable and passed to the child LWC. This I believe would require initializing the child LWC after response is return from callout OR execute the callout from the child as an await function in the async connectedCallback. Thoughts?
Thanks for the feedback. Without seeing the source code, I will make some assumptions here but perhaps you could do the callout in the parent and pass the data down to the child. This provides better decoupling (the LWC only focuses on rendering) and this eases testing.
You would have to ensure that your LWC doesn't crash when passed the initially "empty" data while waiting for the callout. I generally have a "loading" state that displays a spinner while waiting for async data. You can do this in the parent or the child.
@@pozil Thanks for following up. That is interesting you mention the Parent cmp. That was my initial thought; however, my concern was this "loading" state EXACTLY. Do you have a resource or code snippet I could reference that shows this loading state gating? That would be awesome.
@@darrellgallegos6997 I couldn't find one quickly so here's a PR on LWC Recipes with an example: github.com/trailheadapps/lwc-recipes/pull/742/files
@@pozil Thank you I'll check it out.
@@pozil So I took a look at this. I see the spinner for sure. Would the 'inLoading' variable be used in a template directive around the child component to only load the child component when ? This is the way I am understanding concept.