You need to check inside the callback's onSuccess/onFailure method if the callback should still be executed. Something like:
-- service.callServerMethod(new Callback() {
final Item selectedItemOnCallback = currentItem; //currentItem is an instance variable of the presenter
void onSuccess() {
if(selectedItemOnCallback.equals(this.currentItem)) {
// continue work
}
}
}
If this.currentItem changes after the callback as been created if won't execute its onSuccess anymore.
For Activities that are recreated whenever the data changes I use an active flag that is set to true in Activity.start() and to false in Activity.onStop/onCancel. Callbacks then check this boolean flag.
-- 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.
For more options, visit https://groups.google.com/groups/opt_out.
No comments:
Post a Comment