Daniel, First thing, With Asynchronous call you should never get the Stack over flow as Asynchronous calls are running in different thread and your function retursn back before calls finish. But i think you have genuine problem of asynchronous call chains...where writing code become too problematic. I had the same issue and long back i started this discussion that having synchronous calls will be a good idea too., so that you don't need to write async callback and leave it up to the developer if they want to use synchronous calls.
But that time then i had to create a single class with one boolean variable for each kind of call and correpsonding data. So whenevr a call finishes i call the function of that class as MySIngleTonCLass.setLoginCallFNished(true) MySIngleTonCLass.setUser(User) MySIngleTonCLass.refresh(); if some other class finishes then i call something like MySIngleTonCLass.setDataRetrivedCall1(true) MySIngleTonCLass.setDataRetrived1(someData) MySIngleTonCLass.refresh(); MySIngleTonCLass.setDataRetrivedCall2(true) MySIngleTonCLass.setDataRetrived2(someData2) MySIngleTonCLass.refresh(); and then had to write my login in MySIngletonClass to update UI. ( my problem area was updating the UI) so i do something like if(getLoginCallFNished() and user != null) create Logout Link else create loginLink if(getDataRetrivedCall1() and data1!= null) Display the Data else Display No Data found So yopu need to see if such kind of solution will fir to your problem. But definitely asynchrnous call WILL not give you stack overflow. It must be your code somewhere. Ravi On Jun 12, 2:14 pm, daniel <d.brelov...@googlemail.com> wrote: > hi all, > > I hope someone can help to find a solution to the following problem: > > I have some complex code that may need data from the server. When I > make a request I get the data asynchronous, so I have to provide a > callback to handle the response. Now all the code that use this > function need a callback too. But this leads to very long chains of > nested callbacks. Especially when I need to call async methods in a > loop and every call may depend on the previous, I can`t find a way to > do this without calling the method recursive in the onSuccess of the > callback. But this way I get a StackOverflow very fast. > > I can`t request all data first and run the code that needs it after > that, cause which data is needed may depend on the data I already got. > > I have really no idea - hopefully you have > > thx in advance --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to Google-Web-Toolkit@googlegroups.com To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/Google-Web-Toolkit?hl=en -~----------~----~----~----~------~----~------~--~---