On Nov 17, 10:56 am, Ian Bambury <ianbamb...@gmail.com> wrote: > The problem with that is that you have to wait for call A to return before > initiating call B. What if you have 5 or 6 calls. Or the user can submit > different bits as and when? > > The best way is to make a single rpc call which does everything you want out > of A and B when everything is ready. > > If there are too many combinations, then send a set of commands. > > If you want to/have to do it on the client, then you have to check that > everything has returned OK and when they have, do that 'some code' stuff > > You need to have some way to indicate that each call has returned and each > return checks if everything is ready. If you are waiting for data, just > check if the data is there, otherwise use flags. E.g. > > boolean aReturned = false; > boolean bReturned = false; > boolean cReturned = false; > > rpcA() > { > onSuccess() > { > aReturned=true; > check(); > } > > } > > rpcB() > { > onSuccess() > { > bReturned=true; > check(); > }} > > rpcC() > { > onSuccess() > { > cReturned=true; > check(); > } > > } > > check() > { > if(aReturned && bReturned && cReturned) > { > // Do stuff with a, b and c > } > > }
Perhaps a more event-driven system would work, similar to the JDK java.util.concurrent.CountdownLatch class. Create a Countdown class implementing HasValue<Integer>, a CountdownEvent extending ValueChangeEvent<Integer>, initialize a Countdown named latch before the three RPC calls, call latch.countdown() from each of the onSuccess methods, and listen for the count to hit 0 and blastoff. Respectfully, Eric Jablow -- 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-tool...@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=.