Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cancel GWT RequestFactory request

Is there a way to cancel/abort request factory requests? Using GWT 2.3

like image 213
fabiangebert Avatar asked Aug 06 '26 00:08

fabiangebert


1 Answers

There is no way to cancel a request after the fire() method has been called. Consider building a custom Receiver base class such as the following:

public abstract class CancelableReceiver<V> extends Receiver<V> {
  private boolean canceled;

  public void cancel() {
    canceled = true;
  }

  @Override
  public final void onSuccess(V response) {
    if (!canceled) {
      doOnSuccess(response);
    }
  }

  protected abstract void doOnSuccess(V response);
}

The pattern can be repeated for other methods in the Receiver type.

like image 145
BobV Avatar answered Aug 09 '26 12:08

BobV



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!