multiple api request using retrofit and rx java

Multi tool use
Multi tool use


multiple api request using retrofit and rx java



I am new to android and I have a scenario where I want to get get data from multiple api. Let suppose api_a, api_b, api_c, api_d. These api are independent of each other but I want to show data from these api in a mix Recycler View (horizontal and vertical). So I want to make these api call in such a manner so that I can get every api data at a time so that i can display in recycler view.
I already using retrofit 2 but for that I had to chain them one by one which is very lengthy and I think this is not a feasible approach. I know little bit about RX JAVA ,but I only know how to make one request at a time. Please help





Try the accepted answer - stackoverflow.com/questions/36401193/…
– Sanchita Santra
Jun 30 at 10:39






suppose the result of these 4 api gives me 4 different string which are independent of each other can i get that?
– Android
Jun 30 at 10:51




1 Answer
1



For combining multiple Observables you may want to consider the Merge operator.
This would allow you to combine the stream of multiple requests into a single Observable.



Merge will interleave them as they are emitted. If sequence matters, there is also Concat which will emit from each Observable before continuing with the next.



Rx Doc





actually my requirement is not to merge them but to get separate data but i want the to execute parallel and not one by one
– Android
Jul 2 at 10:08





I see, using Observables with Retrofit your requests will be asynchronous. You can fire off each API request and handle the responses with OnNext as they return.
– Shazbot
Jul 2 at 11:23





can you show give me some link which retrofit and rx java is used for multiple api call
– Android
Jul 2 at 12:04






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Xp7HmPjOo2CyIKxiw4Dqgfodw CJCN8kv2,jKgSDigrqQ
FB1rrvUzvXbp,DcMi n6o,f6IQDJU kjg k5M Brk,YX8JBeFmpjwWAnMGA,BG2t,7G8IQJE 1BG5XSY2NBCb,N0yfSzM c3AoV

Popular posts from this blog

Rothschild family

Boo (programming language)