I have a function set up to loop thru an array and perform
specific actions for each item in that array. The problem I'm
having is that the statments aren't executing in the order I'm
intending and I'm guessing it's because they are taking too long
and the loop is moving on before they have finished executing. I'm
trying to figure out if there is way to "pause" my for loop while I
call a function - and make sure that function has returned data
before the loop continues on.
In the attached code you can see the initializeData function
is where I'm looping thru an array of groups. For each group I'm
trying to call "populateCategories()" which will essentially make
an httpService call to load that data. The end result I'm getting
though, is that the httpService is being run the correct number of
times but always with the group information for the final array
position, not each one in order as I'm intending. Is this possible
or is there a better way to go about this?