如何将Function3转换为并行打2个API,而不是3个或更多?

问题描述 投票:0回答:1

我正在使用以下方式并行命中3个API,因为我想看到有像Function4、5、6,如果您想命中更多API但没有Function2 <..>那么要使用什么来命中2个API ?

Observable.zip(
        backendApi.getFCdata("","","",""),
        backendApi.getAKCountry(),
        backendApi.getRecyclerData("","",""),
        Function3<ResponseGetFCData, ResponseAK, List<ResponseMarket>, List<ResponseMarket>> { 
            fcData, akCountry, recyclerData ->

            // Your operation here

            return recyclerData
        })
        .observeOn(AndroidSchedulers.mainThread())
        .doOnSubscribe { /* Loading Start */ }
        .doOnTerminate { /* Loading End */ }
        .subscribe(
                { /* Successfully Synced */ },
                { /* Having error */ }
        )

使用上面的示例将2个API转换后的形式会很有帮助。谢谢。

android observable rx-java rx-android
1个回答
2
投票

您必须为此目的使用BiFunction。检查以下:

© www.soinside.com 2019 - 2024. All rights reserved.