Mmm. I'd prefer to be sure that I have each rpc call complete successfully the last time it ran rather than open up the possibility that one of them completed successfully 3 times and the other two either failed an indeterminate number of times or didn't get called at all.
Depends on the situation, of course. Ian http://examples.roughian.com 2009/11/17 Eric <[email protected]> > On Nov 17, 10:56 am, Ian Bambury <[email protected]> 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 [email protected]. > To unsubscribe from this group, send email to > [email protected]<google-web-toolkit%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/google-web-toolkit?hl=. > > > -- You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=.
