If you need to do this in a few places, I would create a class like this:
On Tuesday, September 17, 2013 9:32:07 AM UTC-4, Anu wrote:
-- public abstract class RepeatingAsyncMethod<T> implements AsyncCallback<T> {
public abstract void sendAsyncRequest();
public abstract boolean shouldRepeat(T result);
public abstract void onComplete(T lastResult);
@Override
public void onSuccess(T result) {
if (shouldRepeat(result)) {
sendAsyncRequest();
}
else {
onComplete(result);
}
}
}
and then make an implementation that calls whatever RPC method you need to call in "sendAsyncRequest", passing "this" as the callback. Then you can implement shouldRepeat to determine whether or not you should repeat.
If you have parameters you need to pass to your RPC, you could put them in the constructor of your subclass and send them each time in sendAsyncRequest.
On Tuesday, September 17, 2013 9:32:07 AM UTC-4, Anu wrote:
I have a method that makes async call and Onsuccess(), it should make this async call again with new set of data and it should continue till the application is alive. Kindly suggest me few options. Also, do we need Timer to achieve this?
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.
For more options, visit https://groups.google.com/groups/opt_out.
No comments:
Post a Comment