Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for RxJava, Observables and LiveData #35

Open
Grandolf49 opened this issue Sep 3, 2020 · 3 comments
Open

Support for RxJava, Observables and LiveData #35

Grandolf49 opened this issue Sep 3, 2020 · 3 comments

Comments

@Grandolf49
Copy link
Collaborator

Summary

Currently, the API response is wrapped in Call<ApiResponse> object.

Expectation

It would be very helpful for the Android Applications to get the response in either Observable or LiveData

@aubryll
Copy link

aubryll commented Feb 12, 2021

@Grandolf49 you can do something like this:

 public static <T> Single<Response<T>> toSingle(Call<T> call){
    val single = SingleSubject.<Response<T>>create();

    call.enqueue(new Callback<>() {
        @Override
        public void onFailure(@NotNull Call<T> call, @NotNull Throwable e) {
            single.onError(e);
        }

        @Override
        public void onResponse(@NotNull Call<T> call, @NotNull Response<T> response) {
            single.onSuccess(response);
        }
    });
    return single;
}

to add support to the methods you are interested in.

@Grandolf49
Copy link
Collaborator Author

@aubryll Thanks for the comment.

Looks good, will try this approach!

@danishjamal104
Copy link
Collaborator

Since we are upgrading to 1.5.0, it consist of dedicated executer class Calls.java. Where we can directly execute query like PostSelfAuthenticationResponse resp = Calls.ok(client.selfAuthentication.authenticate1(""));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants