openMF / fineract-client

Mifos Fineract Client is a Java based library that provides a simple interface to interact with the Apache Fineract 1.x Platform APIs
Mozilla Public License 2.0
14 stars 14 forks source link

Support for RxJava, Observables and LiveData #35

Open Grandolf49 opened 4 years ago

Grandolf49 commented 4 years ago

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 commented 3 years ago

@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 commented 3 years ago

@aubryll Thanks for the comment.

Looks good, will try this approach!

danishjamal104 commented 3 years ago

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(""));