简体   繁体   中英

Wait for multiple network calls to finish using Retrofit without RxJava on Android

I have multiple network calls which are independent of each other but need some processing once all requests are finished.

I found this link which explains this using RxJava.

How can we do this without RxJava?

In your Activity or whatever the received data comes, make variables int numberOfRequestsTotal and numberOfRequests or something. If you know for sure how many requests will be, then you can add number each time any of the requests is finished and check if all requests are finished by checking how many request overall by numberOfRequestsTotal . If number will be equal you're done. I would implement something like this, but it's much easier and better to do using rxjava.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM