Retrofit: Support enqueue with empty callback.

Created on 5 Jan 2016  路  2Comments  路  Source: square/retrofit

like enqueue();, enqueue(null) or enqueue(EmptyCallback).. etc, whatever.
i need executing request and not handling any response job.

i'm using below code at that case:

api.sendLastPosition(38.f, 127.f).enqueue(new Callback<Void>() {
            @Override
            public void onResponse(Response<Void> response, Retrofit retrofit) {

            }

            @Override
            public void onFailure(Throwable t) {

            }
        });

Yes, may be my request feature is unnecessary. so, what code should i using in this case?

Most helpful comment

@devflow You could create a simple class that implements Retrofit Callback's interface:

public class EmptyCallback<T> implements Callback<T> {
  @Override
  public void success(T t, Response response) { }

  @Override
  public void failure(RetrofitError error) { }
}

and then just:
api.sendLastPosition(38.f, 127.f).enqueue(new EmptyCallback<>());

All 2 comments

@devflow You could create a simple class that implements Retrofit Callback's interface:

public class EmptyCallback<T> implements Callback<T> {
  @Override
  public void success(T t, Response response) { }

  @Override
  public void failure(RetrofitError error) { }
}

and then just:
api.sendLastPosition(38.f, 127.f).enqueue(new EmptyCallback<>());

@michaldrabik
Thanks. How did i miss that :sob: .. thanks again.

Was this page helpful?
0 / 5 - 0 ratings