GWT - define async services with a subclass of AsyncCallback

84 Views Asked by At

Does GWT allow to define the async services using a custom subclass of AsyncCallback?

Basically, I'd been suggested to do something similar to How to wrap every Callback in one place to improve error handling but do it in a way where the async service is defined using a custom subclass (or rather, a functional interface, with default error handling, as that would allow simple lambda usage).

In other words, when I have

public interface MyService extends RemoteService {
    Object doTheThing();
}

I'd like to replace

public interface MyServiceAsync {
    void doTheThing(AsyncCallback<Object> callback);
}

with

public interface MyServiceAsync {
    void doTheThing(MyCallback<Object> callback);
}

where MyCallback extends AsyncCallback.

This would be done in all the services and anything that needs refactoring would be refactored appropriately.

Currently doing so just produces errors MyServiceAsync is missing method doTheThing(AsyncCallback<Object>) on the class and Last parameter must be of type AsyncCallback on the method.

The question linked at the start is the only thing I could google up, everything else was about normal async service usage.

0

There are 0 best solutions below