Hello fellow programmers I have this specific case in which I have some trouble thinking of a way to solve my problem.
Let me explain the problem first. We have a JS Object with data to be 'rendered' for each element we need to execute an API call to get its specific attributes. To be perfectly optimized firstly we execute an API call for all elements to be added on the same level ( for instance ) the first level is - add Section, then we see section has children then we execute add all 3 elements on the same level ( adding them together ). But then we see each Element has Child 1 elements that need to be added. And there the fun begins for me because we need to execute an API call for each Element to add its respective Child 1 elements and then check if any of them has more children.
So my problem is when running this all multiple API calls in parallel how can I catch when the last children have been added so I can Execute Render!. I know I can render multiple times but that is not optimized at all ( I tried it and it works ) But I want to use render only 1 time when the last children have been added.
(Note this structure can change we can have 1 level of children or 4 levels.)
So given this structure