Re: Application architecture question
If you have multiple independent RPC requests and you want to update the GUI after all these RPC requests are done, then you could check a number of boolean variables (one per RPC request) to see if all of them are true ( = RPC is done), e.g.
server.rpcMethod1(Callback() {
onSuccess() {
rpcMethod1Done = true;
maybeUpdateUI();
}
});
server.rpcMethod2(Callback() {
onSuccess() {
rpcMethod2Done = true;
maybeUpdateUI();
}
});
private void maybeUpdateUI() {
if(allRpcDone()) { //check all boolean variables.
//... update ui
}
}
But as you have a mobile application its probably better to batch your requests, so that your app, as a rule of thumb, only does one request per screen. This saves a lot of network overhead. In this case a command pattern might be useful, as it allows for easy BatchCommands, e.g.
BatchCommand bc = new BatchCommand();
bc.add(new DoStuff1Command());
bc.add(new DoStuff2Command());
server.execute(bc, Calllback<BatchCommandResult>() {
//in onSuccess iterate over all individual command results contained in the BatchCommandResult and finally update your UI.
}
Otherwise, if you just have a single RPC request somewhere and you make that RPC request because of an event you probably just need an XyzLoadedEvent, e.g. ScoreBoardRequestEvent and ScoreBoardLoadedEvent, just like Joseph has already explained.
-- J.
-- You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.

0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home