Skip to content Skip to sidebar Skip to footer

Calling Four Api's Combining Together Using Rxjava

I am new to RxJava Restapi.class /************/ @GET('app/dashboard') Observable getCategories(@HeaderMap Map headers);

Solution 1:

using this way

List<Observable<?>> observables = Lists.newArrayList(categoriesObservable, walletObservable, settingsObservable, ratingsObservable);
            Observable.merge(observables).toList().subscribe(newAction1<List<Object>>() {
                @Overridepublicvoidcall(List<Object> objects) {
                    // success
                }
            }, newAction1<Throwable>() {
                @Overridepublicvoidcall(Throwable throwable) {
                    // error
                }
            });

or you can using mergeDelayError instead

hope this helps

Solution 2:

You can use Zip operator

Observable<String> result = 
Observable.zip(categoriesObservable, walletObservable, settingsObservable, ratingsObservable, newFunction4<CategoryHomeModel, WalletBalance, Settings, SwapSettings, String>() {
    @OverridepublicStringapply(CategoryHomeModel category, WalletBalance wallet, Settings settings, SwapSettings swap) {
        String res = category.name + wallet.name + settings.name + swap.name;
        // You can customize the final result based upon your requirementsreturn res;
    }
});

Post a Comment for "Calling Four Api's Combining Together Using Rxjava"